Unable to connect from VSCode to remote Ubuntu server using ssh key
- 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:
- Deploy Ubuntu VM in Azure configured to use known good Public Key
- From local machine, use OpenSSH via CMD window to connect to Ubuntu Server using Private Key (this is successful)
- Open VSCode and install the Remote - SSH extension
- Hit CTRL + Shift + P to bring up cmd pallet
- Enter
Remote-SSH: Connect to Host... - Select
Add New SSH Host... - Enter the cmd
ssh <username>@<remote_host> -i C:\Users\<username>\.ssh\id_rsa - Select to add new connection to the
C:\Users\<username>\.ssh\configfile - Hit CTRL + Shift + P to bring up cmd pallet
- Enter
Remote-SSH: Connect to Host... - Select new connection made in step 7 & 8
- In window that opens, select
Linuxas 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.
Same here. I downgraded to 1.44 and it works fine.
@hannibal1296 tried downgrading to 1.44 but the problem persists for me
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
See this comment for a workaround that works on my machine.
See this docs section about fixing file permission errors on windows https://code.visualstudio.com/docs/remote/troubleshooting#_fixing-ssh-file-permission-errors