Reputation: 1099
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.
Upvotes: 38
Views: 90092
Reputation: 11
Set the config path to the new config file
The file config_aws2 is like below
Host 18.abc.xyz
HostName 18.abc.xyz
User ec2_user
IdentityFile C:/Users/dcnha/Desktop/nha/dance_motion/aws/AIkey.pem
set the permission of the .pem
file only for your current user (Windows, https://youtu.be/kzLRxVgos2M), using chmod for Linux
When this dialogue show up, do not click the 18.abc
, instead type in [email protected]
Upvotes: 0
Reputation: 382512
Some other things to check on Winows:
On File explorer, for both:
~/.ssh
directory~/.ssh/id_rsa
remove permissions for everyone except yourself with:
And also ensure that ~/.ssh/config
contains:
Host myhostname
HostName myhostname
User myusername
Tested on Windows 10, vscode 1.78.
Upvotes: 1
Reputation: 895
You can add the private key by following the below steps:
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*
For the IdentityFile
specify the path of your private key. For Windows make sure to use double slashes.Upvotes: 66