Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 [email protected] , 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?

like image 869
Milos Avatar asked Oct 27 '19 10:10

Milos


People also ask

How does VS Code remote SSH work?

The Visual Studio Code Remote - SSH extension allows you to open a remote folder on any remote machine, virtual machine, or container with a running SSH server and take full advantage of VS Code's feature set. Once connected to a server, you can interact with files and folders anywhere on the remote filesystem.

Is VS Code remote SSH safe?

VS Code Remote SSHSSH, or the secure shell protocol, lets you access a remote computer or virtual machine securely over a network connection. You can connect over SSH into another machine from Visual Studio Code and interact with files and folders anywhere on that remote filesystem.

How do I link VS Code to SSH key?

Add SSH key to your VMSelect Use existing public key in the dropdown for SSH public key source so that you can use the public key you just generated. Take the public key and paste it into your VM setup, by copying the entire contents of the id_ed25519. pub in the SSH public key.


2 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
like image 88
Claywalker0929 Avatar answered Oct 07 '22 23:10

Claywalker0929


I had the same problem, and what fixed it for me was disabling remote.SSH.useLocalServer in VS Code's settings.

Source: https://github.com/microsoft/vscode-remote-release/issues/2512

Edit: fix link.

like image 38
Eleanor Holley Avatar answered Oct 07 '22 22:10

Eleanor Holley