Microsoft have released their Remote Development extension for VS code that allows you to run VS Code locally, while using a remote development environment. This is particular useful if you run Windows as your host OS but are doing Linux development, and don’t fancy running Linux as your host OS. Obviously there is other ways to solve the same problem, but this one is actually quite good.
I’m not going to explain all the install steps, Microsoft already have a great guide for that https://code.visualstudio.com/docs/remote/ssh, this post is to cover a few issues I had while getting it to work.
When you have installed VS Code Insider and the Remote Development extension, you need to setup access to your remote development. If you like me previously have been using Putty and PuttyGen, then you need to do a few things.
The first step is to convert your private key file to OpenSSH, that can be done from PuttyGen under Conversions you can select export OpenSSH key, save that key into c:\users\
(assuming you want to use the default locations).
Now open the ssh config, you can do so from VS Code, use F1 type Remote-SSH: Open Configuration File (select the file you want to edit, I’m using c:\users\
Edit the file to look something like
Host sjkpubuntu
HostName yourazurevm.westeurope.cloudapp.azure.com
User yourlogin
IdentityFile C:\Users\
Now you can try to do F1 > Remote-SSH: Connect to Host
Now if you get an error like Can't connect to
then you are in the same situation that I was in, and this error was the reason I wrote this post.
The problem is that the latest version of openssh for windows apparently checks that the permissions on the config file are setup to only allow the following 3 accounts full access (your user account, System and Administrators) if any other account have access to the config file then you get this error.
Now the problem in my case was two fold, my user account wasn’t there (don’t ask me why), and also other accounts had access to the parent folder, and the default is to inherit permissions.
- First I removed permission inheritance on the config file, using
icacls C:\Users\
from an command prompt.\.ssh\config /inheritance:r - Next I assign my own user account full permission to the file using
icacls C:\Users\skp\.ssh\config /grant skp:f
(this command is a bit wierd, because my computer is Azure AD joined, thus my username is skp (no domain), in fact I had trouble using the UI to add my user because of the Azure AD joined machine as I wasn’t able to query for my user account, but luckily icacls worked.
Now with my user account as the only account with access to the config file I’m able to setup the remote workspace and start hacking. You can also add Administrators and System access, but I found it not to be needed.
Categories: Software
Simon,
I was struggling with this problem.
Thanks.
YOU ARE THE BEST THANK YOU FOR THE HELP!!!!!!!!!!!!!
Saved me so much time with the permissions by disabling inhertance and only the three users!!!!!
Thanks so much for this. Apparently I had this error just now (March 2020). Maybe after the last windows 10 update. Bottom line, when establishing only the 3 users as a permission, my SSH remote worked as before. Thanks so much!
Thank you man! Saved me some time 🙂
I ran into this issue while doing the Windows Update to 1803 and solved by uninstalling openSSH
Steps:
Those who are using recent Windows 10 (18.03+ Update and above) will be having OpenSSH installed. You need to uninstall that feature by going to “manage optional features” in Apps and Features menu from Settings. Once uninstalled, install/keep the Git for Windows. It will solve the problem.
Windows 10 1803+ – UnInstall the Windows OpenSSH Client and Install Git for Windows
Earlier Windows – Install Git for Windows
No file permissions issue hereafter for me.
Thank you! The only solution that worked!
THANKS IT WORKS