Menu Home

Visual Studio Code – Remote Development (Bad owner or permissions)

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\<username>\.ssh\<keyname> (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\<username>\.ssh\

Edit the file to look something like
Host sjkpubuntu
HostName yourazurevm.westeurope.cloudapp.azure.com
User yourlogin
IdentityFile C:\Users\<username>\.ssh\<keyname>

Now you can try to do F1 > Remote-SSH: Connect to Host

Now if you get an error like Can't connect to <server>: unreachable or not Linux x86_64 (Bad owner or permissions on C:\\users\\<username>/.ssh/config 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.

  1. First I removed permission inheritance on the config file, using icacls C:\Users\<username>\.ssh\config /inheritance:r from an command prompt.
  2. 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 J.K. Pedersen

Leave a Reply

Your email address will not be published. Required fields are marked *