Connect to Host with VSCode using the private key

Viewed 11354

I want to connect to a remote server, I know the username and hostname, and I also have the private_key.pem file. How can I connect to this virtual machine using VSCode?

I get this error with the solutions on the internet, and that's reasonable because I have not imported this private_key.pem file anywhere, and I do not know how.

Permission denied (publickey)

Thanks for your help.

I use windows, but the remote machine is ubuntu.

1 Answers

Thanks for asking the question. You can add private key in ssh Open Configuration File of visual studios. Please follow the below steps:

  1. Open Vscode

  2. Press F1 and search for Remote-SSH: Open Configuration File

  3. Edit the file for adding new server and private

    Host name-of-ssh-host-here
    User your-user-name-on-host
    HostName host-fqdn-or-ip-goes-here
    IdentityFile C:\path\to\my\id_rsa.

  4. IdentityFile specify the path of private file.For windows use double slash.

Please find the reference at https://code.visualstudio.com/docs/remote/ssh#_getting-started

Related