Skip to content

Instantly share code, notes, and snippets.

@jgmac1106
Created April 3, 2019 23:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgmac1106/ea518f5113f786bdb80efec304a177f5 to your computer and use it in GitHub Desktop.
Save jgmac1106/ea518f5113f786bdb80efec304a177f5 to your computer and use it in GitHub Desktop.
sample post
<article class=-"h-entry">
<h2 class="p-name">Cannot SSH from WSL</h2>
<time class="dt-published" datetime="2018-06-30 12:00:00">Published Jun 30, 2018</time> in posts by <a class="p-author h-card" href="https://blog.johanbove.info">Johan Bove</a>
<span class="p-summary">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.</span>
<div class="e-content">
I’m currently on Windows 10 Pro, Version 1803 (OS Build 17134.112).
When trying to SSH into my remote server from a Ubuntu Bash for Windows 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 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.
</div>
</article>
@johanbove
Copy link

johanbove commented Apr 4, 2019

Thanks for the example. I think there is a typo though; in the very first line, the value for the class on the element article has a ‘-‘ character after the ‘=‘ and before the ‘“h-entry”’

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment