Skip to content

Windows Subsystem for Linux (WSL)

Created: 2018-09-12 21:35:29 -0700 Modified: 2018-09-13 13:32:48 -0700

WSL is split into two filesystems:

  • / - this is your Linux filesystem
  • /mnt/DRIVE_LETTER - this is your Windows filesystem

Files in Linux are not accessible via Windows. Your home directory (~ or $HOME) is “/home/username” by default, NOT your %userprofile% from Windows. I tried modifying this when I first tried switching (via these instructions to modify /etc/passwd), but I ran into issues so quickly that I undid it; “git pull” tried using my Windows .ssh folder, which led to permissions issues since Linux doesn’t understand Windows permissions.

I don’t know exactly what’s open by default to the Internet via WSL, but regardless, it’s a good idea to have a strong password. You can change this by running “passwd”.

First of all, the only real reason I want to switch is so that I don’t have to type my password into Git every time I use it via CMD. I could just use Bash for Windows instead of WSL, but I figured WSL was worth a shot.

I modified my ~ directory to point to Windows instead of Linux, realized that was a terrible decision due to permissions problems, and undid the change.

I set up a brand new SSH key, followed these instructions to be asked my key’s password at first startup, then made sure “git pull” worked. It did.

That’s when I promptly stopped using WSL—I wanted this to work in Visual Studio Code, and I couldn’t seem to do that by launching VSC from WSL (it had permissions errors when trying to use or create a key or something; I don’t know).

~> ssh-add /mnt/c/Users/agd13_000/.ssh/id_rsa
Permissions 0777 for '/mnt/c/Users/agd13_000/.ssh/id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.

You can’t have your SSH key be on your Windows filesystem since “chmod” does nothing there. The reference link says to copy the SSH key to your Linux filesystem, then chmod 600 it.

$ cp /mnt/c/Users/agd13_000/.ssh/id_rsa /home/adam/.ssh/

$ chmod 600 /home/adam/.ssh/id_rsa

$ ssh-add /home/adam/.ssh/id_rsa

Note: you’ll get a very similar issue if you modify your HOME directory to point at Windows and then try doing a “git pull”:

/mnt/b/Code/BotLand/botland> git pull

Bad owner or permissions on /mnt/c/Users/agd13_000/.ssh/config

fatal: Could not read from remote repository.

Please make sure you have the correct access rights

and the repository exists.