Vscode-docs: Bad Owner or Permissions on username\.ssh\config file

Created on 5 Nov 2019  路  25Comments  路  Source: microsoft/vscode-docs

When using vscode-remote it shows C:\\Users\\username/.ssh/config.

Tried to fix following the doc at https://github.com/microsoft/vscode-docs/blob/master/docs/remote/troubleshooting.md#fixing-ssh-file-permission-errors

But the command seems not work for me:

image

remote support-request

Most helpful comment

Screenshot_34
I resolved this problem when added obvious path for .ssh config as "C:\User\Alexander\.ssh\config" (use double slash). It is working for me.

All 25 comments

@mashirozx The issue you reference was in fact resolved with this script, so if the script isn't running, that's something else.

Are you using the Windows OpenSSH client in Windows 10 1803+? If not, you can try to manually set the permissions on config and other files in the .ssh folder to SYSTEM, Administrators, and your user instead.

@Chuxel
System: Windows 10 Home 1903
OS build: 18362.418

Actually I solved this problem in vscode-remote by modifying remote.SSH.configFile and remote.SSH.path and copying C:\Windows\System32\OpenSSH\ to my own directory. I think this could be showed in the docs (maybe not recommend but it works and is really easy) since the PowerShell scripts seems not really work (on all devices).

@mashirozx I'd rather not include something without an understanding of what the problem was to begin with - the configFile is covered elsewhere.

This seems to be a signature error which shouldn't be possible. The only thing I can think of is you are on Home instead of Pro or Enterprise. This is the first time this error has been reported, so something strange is going on.

@Chuxel Maybe this should be a new issue in https://github.com/PowerShell/Win32-OpenSSH/? 馃槀

@Chuxel Actually there is also an issue relate to the Windows version (I guess) https://github.com/PowerShell/Win32-OpenSSH/issues/1445

Yeah that looks like the issue! Let's close this as a upstream duplicate of that problem. Since its not related to VS Code.

@Chuxel I also encountered this problem. Is it because of the path?
image
Instead of "C:\Users\username\.ssh\config"

@hacksut3l I fixed this by setting the path in my ssh config file to C:/Users/[name]/.ssh/config or wherever your config file lives. The important part here is to use forward slashes, not the windows standard backslashes. I think this is because the Windows 10 OpenSSH client is resolving paths with PowerShell under the hood which supports both path delimiters.

For example:

Host ExampleHost
  HostName 1.2.3.4
  IdentityFile C:/Users/johndoe/.ssh/id_rsa
  User johndoe

@mmmeff That is the problem!:+1:

@mmmeff Spent 2 hours finding the issue, then came across this. Worked like a charm!

Can confirm guys, the solution of @mmmeff is working. Should not we open another issue to fix it since by default the extension does not work.

Screenshot_34
I resolved this problem when added obvious path for .ssh config as "C:\User\Alexander\.ssh\config" (use double slash). It is working for me.

Screenshot_34
I resolved this problem when added obvious path for .ssh config as "C:\User\Alexander.sshconfig" (use double slash). It is working for me.

Thanks!

Screenshot_34
I resolved this problem when added obvious path for .ssh config as "C:\User\Alexander.sshconfig" (use double slash). It is working for me.

thank you very much锛寉ou solved my problems

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. enjoy.

P.S. I ran into this issue while doing the Windows Update to 1803 and solved by uninstalling openSSH

Screenshot_34
I resolved this problem when added obvious path for .ssh config as "C:\User\Alexander.sshconfig" (use double slash). It is working for me.

Thanks my friend! 馃憤 This even works without uninstalling the OpenSSH Client on Windows

I suddenly encountered this issue after login Windows with another account and then login back. Before that I didn't touch the default path of .ssh/config
Is this BUG of vscode or specific version of Windows 10?

I believe this issue should be re-opened since the _default_ configuration is broken. This should just work out of the box.

@hacksut3l I fixed this by setting the path in my ssh config file to C:/Users/[name]/.ssh/config or wherever your config file lives. The important part here is to use forward slashes, not the windows standard backslashes. I think this is because the Windows 10 OpenSSH client is resolving paths with PowerShell under the hood which supports both path delimiters.

For example:

Host ExampleHost
  HostName 1.2.3.4
  IdentityFile C:/Users/johndoe/.ssh/id_rsa
  User johndoe

On my system the issue was resolved by:

  1. setting the IdentityFile path as reported above.
  2. defining custom config path for applications like vs code

For me this was caused by the default ssh client. I got the same error when I used ssh through cmd.exe.

What solved it was using a different ssh client, e.g. the git bash ssh client. Add the following entry to your settings.json file:
"remote.SSH.path": "C:/Program Files/Git/usr/bin/ssh.exe"

@MrMarshall Thanks, now run OK!

I just fix this problem. Let me tell you the real reason: Don't use Putty Key Generator!

After OpenSSH was built in Windows 10, VSCode will always use the standard key format.

Open your terminal, use the command ssh-keygen -t rsa -b 2048 -C "username" (must be a Capitalized character C)

Then use your file manager or cd in Terminal to find out the default SSH folder on Windows 10 C:\Users\Username\.ssh. You will find the private key generated just now has no extension. But if you use Putty Key Generator, your private key will have a *.ppk extension. That's the real cause for Key Denied!

VSCode will use the default folder C:\Users\Username\.ssh for you, so you don't need to write any SSH Key Path into the config file. But if you use another SSH library, maybe you need to edit something. (When you follow the GUI of VSCode, you will see the default SSH folder path.)

The last thing to do is upload the *.pub file to the server (or open with VSCode to copy and paste text contents into VPS Console). When done, you can login to the server directly. The information included in the config file will be used automatically.

Make sure your config file has these fields:

Host       easy_edit_to_show_in_the_tree_panel    #no need to use quote mark
HostName   ipaddress_of_the server                #number                     
User       generated_with_-C                      #no need to use quote mark
Port       port_you_set, default_is_22            #number

If you want to save the private key in a special folder to let many programs use at the same time and manage them easily, just add a new keyword IdentityFile to the config file. Only with path after it (be careful with \).

Sometimes c:\Users\your_username\.ssh\known_hosts stores non-corret information. You can just delete all (or single) information about servers in known_hosts and then you will find the connection works. New information will be wrote into the known_hosts again after you login the new server successfully.

I think I found an alternative solution to this issue in this Stackoverflow answer: https://stackoverflow.com/a/58275268/345722

Was this page helpful?
0 / 5 - 0 ratings

Related issues

krave1986 picture krave1986  路  4Comments

gitdudek picture gitdudek  路  7Comments

bpasero picture bpasero  路  6Comments

jrieken picture jrieken  路  4Comments

krokofant picture krokofant  路  7Comments