Reputation: 913
I have a remote ssh server on which I want to do remote developement.
My public key is added to the authorized keys on the server and my private key is passphrase protected.
I added the remote host as described here using ssh user@host -i ~/.ssh/key
But whenever I try to open a new VSCode window on the remote host it fails and I see in the log that the connection timed out, which is expected because I don't get asked for my private-key passphrase.
I read this post on remote development using ssh and I searched on google but couldn't find any hints to what I could do to enable/enter ssh-key passphrase while connecting to remote host.
I know I can connect to the remote using a non-passphrase-protected key but I'm not asking for that, I want to know if it's possible to connect to a remote host from VSCode using a passphrase protected key.
Upvotes: 6
Views: 29984
Reputation: 1175
This is what solved it for me, your issue could be different.
Remote-SSH: Open SSH Configuration File...
C:\Users\[USER_NAME]\.ssh\config
. Make sure you have appropriate permissions.Host Custom_Name HostName example.server.com User your_user_name IdentityFile C:\Users\[USER_NAME]\Documents\MobaXterm\home\.ssh\id_rsa (or wherever you have the private key)
{ // add custom configuration file path "remote.SSH.configFile": "C:\\Users\\[USER_NAME]\\.ssh\\config", // Other settings // omit comma after *config"* if that is your last setting }
Now it should ask for passphrase as opposed to password.
P.S. Here is a lot of useful information with the setup, especially with the keys that I have omitted for brevity.
Upvotes: 0
Reputation: 1323263
If your key is not the default one, that means you need a ~/.ssh/config entry in which you specify your SSH connection parameters:
Host myserver
Hostname host
User user
IdentityFile ~/.ssh/key
The Visual Studio Code Remote Development will automatically read the config file, and when you ask for opening an SSH session, you will see "myserver" entry: if you select it, the SSH session opened will use ~/.ssh/key
, the right private key.
Then, as long as your ssh-agent is enabled, and you have entered at least once your passphrase (through a manual ssh myserver
), VSCode will use the same agent to get the passphrase when it will need it.
Upvotes: 4