vscode-remote-release icon indicating copy to clipboard operation
vscode-remote-release copied to clipboard

Unable to connect from VSCode to remote Ubuntu server using ssh key

Open Phydeauxman opened this issue 6 years ago • 5 comments

  • VSCode Version: 1.45
  • Local OS Version: Windows 10 1909(18363.836)
  • Remote OS Version: Ubunt 18.04
  • Remote Extension/Connection Type: SSH

Steps to Reproduce:

  1. Deploy Ubuntu VM in Azure configured to use known good Public Key
  2. From local machine, use OpenSSH via CMD window to connect to Ubuntu Server using Private Key (this is successful)
  3. Open VSCode and install the Remote - SSH extension
  4. Hit CTRL + Shift + P to bring up cmd pallet
  5. Enter Remote-SSH: Connect to Host...
  6. Select Add New SSH Host...
  7. Enter the cmd ssh <username>@<remote_host> -i C:\Users\<username>\.ssh\id_rsa
  8. Select to add new connection to the C:\Users\<username>\.ssh\config file
  9. Hit CTRL + Shift + P to bring up cmd pallet
  10. Enter Remote-SSH: Connect to Host...
  11. Select new connection made in step 7 & 8
  12. In window that opens, select Linux as the platform

VS Code throws an error saying it could not establish connection to the remote server and that the process tried to write to a nonexistent pipe. Output window has line saying Bad owner or permissions on C:\\Users\\<username>/.ssh/config.

After creating the config file, ssh to the remote server no longer works using OpenSSH from the cmd window. Attempting to connect via ssh from the cmd window will now also generate the line saying Bad owner or permissions on C:\\Users\\<username>/.ssh/config.

Deleting the config file from the C:\Users<username>.ssh folder will allow ssh to start working again from the cmd line.

Have validated this behavior on 2 different machines.

Phydeauxman avatar May 14 '20 01:05 Phydeauxman

Same here. I downgraded to 1.44 and it works fine.

burning-croissant avatar May 14 '20 08:05 burning-croissant

@hannibal1296 tried downgrading to 1.44 but the problem persists for me

Phydeauxman avatar May 14 '20 09:05 Phydeauxman

Performed some additional testing this morning. Reconfigured remote host to allow password auth.

From VSCode, with no config file in my C:\Users\<username>\.ssh\ folder, if I attempt to connect to the remote host using the command <username>@<ip_address>, I get prompted for the system type, then the password, and then I am successfully connected. It is interesting to note that if when entering CTRL + SHIFT + P, selecting Remote-SSH: Connect to Host... and the selecting Add New SSH Host..., the example entry in the dialog box is ssh [email protected] -A. If you try connecting to a remote host using this format...it will FAIL.

The presence of a config file in my /.ssh folder will kill the ability to SSH to the remote host defined in the config file from any program. Seems more like an issue with the OS than with VSCode yet all the articles I have found point to permissions causing this issue. I do not see anything wrong with the permissions on either one of my systems.

What does appear to be a problem specifically with VSCode is the inability to use a key file in any form. From VSCode, I can connect to remote a system using <username>@<ip_address> but when I try to use <username>@<ip_address> -i C:\Users\<username>\.ssh\id_rsa it throws an error saying Could not resolve hostname <ip_address> -i C:\Users\<username>\.ssh\id_rsa.

When attempting to connect with -i C:\Users\<username>\.ssh\id_rsa <username>@<ip_address> it throws an error saying Warning: Identity file C:\Users\<username>\.ssh\id_rsa <username>@<ip_address> not accessible: No such file or directory

Phydeauxman avatar May 14 '20 11:05 Phydeauxman

See this comment for a workaround that works on my machine.

daixtrose avatar Aug 21 '20 09:08 daixtrose

See this docs section about fixing file permission errors on windows https://code.visualstudio.com/docs/remote/troubleshooting#_fixing-ssh-file-permission-errors

roblourens avatar Nov 06 '20 01:11 roblourens