Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad Owner or Permissions on username\.ssh\config file #3210

Closed
mashirozx opened this issue Nov 5, 2019 · 37 comments
Closed

Bad Owner or Permissions on username\.ssh\config file #3210

mashirozx opened this issue Nov 5, 2019 · 37 comments

Comments

@mashirozx
Copy link

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

@mashirozx
Copy link
Author

mashirozx commented Nov 5, 2019

@Chuxel Seems microsoft/vscode-remote-release#119 still not fix 😭

@Chuxel
Copy link
Member

Chuxel commented Nov 6, 2019

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

@mashirozx
Copy link
Author

mashirozx commented Nov 6, 2019

@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).

@Chuxel
Copy link
Member

Chuxel commented Nov 6, 2019

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

@mashirozx
Copy link
Author

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

@mashirozx
Copy link
Author

@Chuxel Actually there is also an issue relate to the Windows version (I guess) PowerShell/Win32-OpenSSH#1445

@Chuxel
Copy link
Member

Chuxel commented Nov 6, 2019

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 Chuxel closed this as completed Nov 6, 2019
@hacksut3l
Copy link

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

@mmmeff
Copy link

mmmeff commented Dec 29, 2019

@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

@mashirozx
Copy link
Author

@mmmeff That is the problem!:+1:

@prashanthc97
Copy link

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

@Atem18
Copy link

Atem18 commented May 3, 2020

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.

@karpulix
Copy link

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.

@phuonghx
Copy link

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.

Thanks!

@iswangaiguo
Copy link

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.

thank you very much,you solved my problems

@ghost
Copy link

ghost commented Jul 22, 2020

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

@conix67
Copy link

conix67 commented Aug 23, 2020

This fixed the same issue for me - microsoft/vscode-remote-release#119

@Stevemaster92
Copy link

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.

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

@zxbuaa
Copy link

zxbuaa commented Sep 14, 2020

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?

@doxxx
Copy link

doxxx commented Sep 30, 2020

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

@m3hdad
Copy link

m3hdad commented Sep 30, 2020

@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

@marcelrend
Copy link

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"

@solinad21
Copy link

@MrMarshall Thanks, now run OK!

@timeneverdie
Copy link

timeneverdie commented Dec 5, 2020

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.

@doxxx
Copy link

doxxx commented Dec 9, 2020

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

@skeddles
Copy link

This took me forever to figure out.

First I had to use the suggestion from here: #3210 (comment)
Which was going to the settings of the extension and setting the custom config file path to the ./ssh/config file (making sure there are forward slashes only).

I then also had to change the permissions on the key file I was using, described here: https://superuser.com/a/1296046/302150

Ultimately this was way too hard to figure out, I've wasted hours. If you for some reason can't fix the fact that the default path doesn't work at all, you could at least provide error messages that actually explain the problem and tell us how to fix it.

@tmontney
Copy link

tmontney commented Nov 1, 2021

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.

Still an issue, and this fixed it. Since I had to set the Config File path, it means the default is bad.

VSC: 1.61.2
Remote-SSH: 0.65.8

@mldisibio
Copy link

mldisibio commented Nov 4, 2021

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

Happened to me right after IT Support logged in as Admin. Removing them (and disabling inheritance) using Security dialog on .ssh folder fixed the issue.

@choncba
Copy link

choncba commented Dec 1, 2021

Solved for me adding absolute path to ssh config file in vs code ssh settings.

@microsoft microsoft deleted a comment from inamahamed Jan 12, 2022
@kangarooo
Copy link

kangarooo commented Mar 28, 2022

Needed to edit myself to get rid of it
image

@xDaniCh
Copy link

xDaniCh commented Mar 31, 2022

Пришлось отредактировать себя, чтобы избавиться от него изображение

Great, that really helped.

@xiay-lcw
Copy link

xiay-lcw commented Dec 1, 2022

In my case, the file permission was indeed corrupted. I tried to manually fix the permission on the file but did not work. I guess there are hidden permission properties openssh would check for but not exposed in windows explorer GUI.

I ended up creating a new file and copy over the content...

@Electromorphous
Copy link

Electromorphous commented Jan 29, 2023

I'm on ubuntu and my terminal was working perfectly fine with git and the ssh config file. I was able to clone as well as push code. But the vs code integrated terminal kept giving the "Bad owner or permissions" error.

None of the above-stated solutions was helpful to me as I'm on Ubuntu. Therefore I found this.

Basically, I just ran the 2 commands given below

sudo chmod 700 ~/.ssh
sudo chmod 600 ~/.ssh/*

@advra
Copy link

advra commented Sep 7, 2023

Needed to edit myself to get rid of it image

This is a great alternate solution if one does not have admin privs.

@pimentelleo
Copy link

Got this error while trying to connect into a server that uses a pubkey.
I solved on my side by changed the permissions of the file itself to only me full access and it worked.

@Vaarun-Kamath
Copy link

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.

OMG IT WORKS 😭

@CristiFati
Copy link

CristiFati commented Nov 15, 2024

@mmef solution (#3210 (comment)) works for me (SSH Win -> Nix) with the following notes:

  • It didn't work for a key file located somewhere on my E: drive

  • I had to SymLink it in my home dir (mklink "C:\Users\cfati\.ssh\link_to_key_file" "E:\${actual_path_to_key_file}")

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

No branches or pull requests