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 %USERPROFILE%\.ssh\config file on Windows 10 #119

Closed
bunnyvishal6 opened this issue May 4, 2019 · 14 comments
Closed
Assignees
Labels
ssh Issue in vscode-remote SSH

Comments

@bunnyvishal6
Copy link

  • VSCode Version: 1.34.0 insiders(user setup)
  • Local OS Version: Windows 10 1809
  • Remote OS Version: Ubuntu 18.04 lts
  • Remote Extension/Connection Type: SSH

Steps to Reproduce:
When I try to connect this is the error
Can't connect to VM-IP: unreachable or not Linux x86_64 (Bad owner or permissions on C:\Users\Bunny/.ssh/config). But vm is ubuntu 18.04 and x86_64.

Here are my file permissions

vscode-remote-1

vscode-remote-2

Does this issue occur when you try this locally?: Yes
Does this issue occur when you try this locally and all extensions are disabled?: No

@bunnyvishal6
Copy link
Author

According to this doc, the ./ssh/config file only user should have access to it.
image,

Which is a contradiction to this doc
image


So by removing all other permission entries from above list I can successfully run ssh from powershell or cmd but, cannot connect from vscode.

@kieferrm kieferrm added doc ssh Issue in vscode-remote SSH labels May 4, 2019
@murilogiatti
Copy link

image

It is working for me like this.
Just my user...

@bunnyvishal6
Copy link
Author

@murilogiatti .This is still not working for me

image

@murilogiatti
Copy link

image

it is in the key file permissions, both private and public...

@bunnyvishal6
Copy link
Author

bunnyvishal6 commented May 4, 2019

@murilogiatti, My key file permissions are also same but not working. Can I contact you in private?

@Chuxel
Copy link
Member

Chuxel commented May 4, 2019

@bunnyvishal6 Yeah, the permissions in the document are exactly how things are set up on my machine. I suspect something else may be going on here.

@Chuxel Chuxel removed the doc label May 4, 2019
@bunnyvishal6
Copy link
Author

@Chuxel Vscode remote dev doc says we need to give full control to user, Administrator and system. But doing so I cannot connect ssh from cmd or powershell, it gives Bad owner or permissions error. And also cannot connect via vscode same error. But by removing all Principals from /.ssh/config file permissions list, I can connect via cmd or pwershell with a normal ssh command. As Win32-openssh config file should not have anyother people to access otherthan owner.

@Chuxel
Copy link
Member

Chuxel commented May 5, 2019

@bunnyvishal6 Windows unfortunately has lots of variations of the SSH clients that may be in your path.

If you're using the official Windows 10 OpenSSH install, there is a utility you can use to set permissions. https://github.com/PowerShell/openssh-portable/blob/latestw_all/contrib/win32/openssh/FixUserFilePermissions.ps1

Here's a snippet you can cut-and-paste in an administrator's powershell window to run it.

Install-Module -Force OpenSSHUtils -Scope AllUsers
Repair-UserSshConfigPermission ~/.ssh/config
Get-ChildItem ~\.ssh\* -Include "id_rsa","id_dsa" -ErrorAction SilentlyContinue | % {
    Repair-UserKeyPermission -FilePath $_.FullName @psBoundParameters
}

If you still get an error, it's possible you're using a older or different version of the tools than Win 10 ships with or there's more than one on your system and one is getting picked up in some scenario.

@bunnyvishal6
Copy link
Author

bunnyvishal6 commented May 5, 2019

@Chuxel, Did you get your setup working with this? I recently re installed win10. And the openSsh is the default one that comes with installation. And after installing above module, it says opensshutils.psm1 scripts are disabled. Is there a way to update openSsh client?

Is this the latest openssh client in windows10
Annotation 2019-05-05 131009

I think my openssh client is version 0.0.1.0 and utils version is 0.0.2.0. I will uninstall current version and will install from github repo of win32-openssh

@Chuxel
Copy link
Member

Chuxel commented May 5, 2019

@bunnyvishal6 Don't install from the GitHub repo since that could be causing your problems - those are going to be development builds. Use the version that ships with Windows 10. It is known to work.

You do not need to download the script. Just cut and paste the following from an administrator power shell window.

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process
Install-Module -Force OpenSSHUtils -Scope AllUsers
Repair-UserSshConfigPermission ~/.ssh/config
Get-ChildItem ~\.ssh\* -Include "id_rsa","id_dsa" -ErrorAction SilentlyContinue | % {
    Repair-UserKeyPermission -FilePath $_.FullName @psBoundParameters
}

If you get an error, please post it - no way to know what is going wrong otherwise.

@bunnyvishal6
Copy link
Author

bunnyvishal6 commented May 6, 2019

@Chuxel, I'm getting this error when i try to run above commands in elevated powershell
image

@Chuxel
Copy link
Member

Chuxel commented May 6, 2019

@bunnyvishal6 Run:

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

...or if you want this to only apply to the current window...

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope Process

@bunnyvishal6
Copy link
Author

bunnyvishal6 commented May 6, 2019

@Chuxel Thanks a lot. It worked. Not relevant, But I expected a demo of this today at MS Build 2019 But they just mentioned it. Anyway this is an awesome feature and I'm loving it.

@Chuxel
Copy link
Member

Chuxel commented May 7, 2019

@bunnyvishal6 Great! Updated the docs to recommend this script. Re: //build - Yeah we announced at PyCon last week but it's going to show up in a number of spots over the week!

@Chuxel Chuxel closed this as completed May 7, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 21, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
ssh Issue in vscode-remote SSH
Projects
None yet
Development

No branches or pull requests

4 participants