Visual Studio Code Remote SSH uses Windows username instead of username in ssh_config

Viewed 11177

I'm using Visual Studio Code on Windows 7, along with Microsoft's Remote SSH extension. I added new remote host, and saved configuration in ssh_config file.

When I open that file, everything looks ok, both User and Host values. However, when extension asks me for a password, I can see that it doesn't use myuser@myremotehost.com , values that are written in ssh_config files, instead it uses proper host but it also uses my windows username instead of the username I set in ssh_config file.

Any solutions to that?

5 Answers

I found that including the username in the Host definition of the .ssh config file fixed it for me.

Edit the contents of C:/Users/me/.ssh/config from:

Host bar
  User foo
  HostName bar
  ForwardAgent yes

to:

Host foo@bar
  User foo
  HostName bar
  ForwardAgent yes

I found the problem. When using Command Palette and running Remote-SSH: Connect to host, you can add your host, and then save it for future use. Now, when saving config, it will ask you which file do you want to save your configuration to, and I was presented with 2 options:

  • ssh_config(which is in ProgramData)
  • config(which is in Windows/Users/MYUSER/.ssh/)

Now, I first tried latter, but it couldn't find the file, so I went with former, ie ssh_config. That's why I had this problem.

To fix it, I went to Windows/Users/MYUSER/.ssh/ and created a blank file there. After that, I added new host, saved it to newly created config file, and, voila, everything works as expected.

I tried the following steps as I use Windows 10:

  1. Install the Windows OpenSSH Client
  2. Install the Windows OpenSSH Server
  3. Run the VS Code as Administrator

and it works.

what I have done was this:

1- Add new host : ssh user_name@IP_Adrress

2- Select connect to host and it worked like a charm

Related