5

I'm using Mac OS and can succesfully connect via terminal and ssh to the host with the command

ssh -i ~/full/path/to/private_key name@ip

But when I try to use the exact same command in Visual Studio Code using Remote-SSH "Connect to Host", it returns me "Could not establish connection to "ip": Permission denied (publickey)".

How to fix it? I've tried to add my local public key to the authorized_keys on host, but it didn't help.

Astralpirate
  • 83
  • 1
  • 6

2 Answers2

3

Ensure you have read-only access to the private key.

Run the following to do so.

chmod 400 ~/.ssh/<path_to_your_key.pem>
Arvind Reddy
  • 406
  • 2
  • 10
1

please try this..

After you click "Connect to Host", ONLY type in IP address (remove "ssh -i ~/full/path/to/private_key name@" from your example). It will then ask you to enter the passphrase for the ssh key. It should work if the passphrase is correct.

PS: Please also make sure you have the config information in the ssh configuration file ready. See details here.

hiro tang
  • 144
  • 1
  • 5