netdjw
netdjw

Reputation: 5997

Why asking password VS Code Remote SSH plugin if I use public key to authenticate?

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?

Upvotes: 6

Views: 8895

Answers (3)

RobbieC
RobbieC

Reputation: 472

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.

Upvotes: 2

alexgo
alexgo

Reputation: 41

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

Upvotes: 3

KotaKotik22
KotaKotik22

Reputation: 11

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

Upvotes: 1

Related Questions