Cannot SSH from WSL

The following 301 words were published by Johan Bové on .

This is a post explaining how I got around the issue that you cannot load up an .ssh key for a SSH session from within the Windows Subsystem For Linux.

I'm currently on Windows 10 Pro, Version 1803 (OS Build 17134.112).

When trying to SSH into my remote server from a (Windows Subsystem for Linux)[https://docs.microsoft.com/en-us/windows/wsl/install-win10] terminal, I was greeted by this lovingly designed error message:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0777 for '/mnt/c/Users/Johan/.ssh/private-key_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.

So I went out on the Intarwebs to look for a fix.

My (DuckDuckGo Search)[https://duckduckgo.com] found the following issue on the WSL GitHub project, posted by @ArturChe: https://github.com/Microsoft/WSL/issues/3181

Arthur's issue got quite a few replies and the reply that helped me out, was the one that mentioned this MSDN blog post by Craig Wilhite

It taught me that you can mount the Windows Drive C including metadata... And this flag should fix the file permissions notification. The post is a little technical, but the explanation clear and best of all, it worked!

I can now use my .ssh key again!

So in short, my fix for this issue was to follow the instructions to umount and mount the C with the 'metadata' flag.

sudo umount /mnt/c
sudo mount -t drvfs C: /mnt/c -o metadata

To make Windows Subsystem For Linux always mount the Windows drive including metadata, you'll need to follow the instructions fromthis other MSDN blog post.

For the moment I haven't encountered any side-effects for this and the SSH connection works.