6

I just started using Remote - SSH (ms-vscode-remote.remote-ssh) plugin. I put this code into settings.json:

    "remote.SSH.remotePlatform": {
        "myserver": "linux"
    }

In the config file:

Host myhost
  HostName myhost
  User root
  IdentityFile ~/.ssh/id_rsa.pub

Exactly as the documentation said, and I expected - like in the PuTTY - the plugin just log in and done, but it still asking password for login.

Is there any setting what I missed? Or is there any setting what I must apply to avoid asking password?

Gama11
  • 31,714
  • 9
  • 78
  • 100
netdjw
  • 5,419
  • 21
  • 88
  • 162

3 Answers3

3

You need to use the private key as mentioned below. Additionally, you need to copy the contents of your public key file (the one that ends with .pub), to a file called "authorized_keys", usually located under ~/.ssh

alexgo
  • 41
  • 5
  • Different SSH clients and servers use different methods for storing their public and private keys, and whenever I need to set up some client/server pair, I need to find out how/where to store the keys. In this case, connecting a VSCode on a Windows machine to a server on a SLES machine (with the particular SSH server my company uses), this answer's location for the private key on the server was what saved the day. Thanks. – Amitai Irron Nov 03 '20 at 21:07
  • 3
    My public key is already added to authorized_keys, but still nothing. – netdjw Nov 19 '20 at 14:33
2

For Windows 10, if you have stumbled across this issue using the Remote - SSH plugin, run the following in PowerShell (as admin):

# Make sure you're running PowerShell as an Administrator
Set-Service ssh-agent -StartupType Automatic
Start-Service ssh-agent
Get-Service ssh-agent

And then if you already generated a key, do ssh-add. It should then prompt you for the passphrase of your key, then you should get a message that your key has been set as the default identity. Open up VSCode and try again.

RobbieC
  • 422
  • 3
  • 17
1

You are supposed to use the private key, if your public key is ~/.ssh/id_rsa.pub then the private key is probably ~/.ssh/id_rsa