sshopensshwindows-11

openSSH Client Connection to EC2 Instance Permission setting


I want to establish a SSH connection to EC2 Instances on AWS using the onboard OpenSSH client on windows 11.

The Client is installed and running (checked with Get-Service sshd).

I also created a .ssh\config in my $Home Folder.

I put the following the config file:

Host my_host
 HostName localhost
 User my-username
 IdentityFile .ssh\xxx.pem

Then I created a Keypair on AWS - keypair.pem. I moved it into the .ssh\ directory After that I added it to the config:

ssh-add xxx.pem

But i never showed up in the .ssh\config...

I checked the properties of the .pem file and made sure, I am the owner and have full control.

When I try to connect like this:

ssh ec2-user@ec2-x-xxx-xxx-xxx.eu-west-1.compute.amazonaws.com

I get the following error:

Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

Question 1: where is the info stored, when I add the .pem file (ssh-add xxx.pem)? Question 2: How can I solve the permission error with the file, is there anything I'm missing?

Thanks in advance

A


Solution

  • ssh-add adds keys to the SSH agent, not the SSH config. The SSH agent stores keys securely in memory so that they're ready for use; it's a timesaver overall, especially if you use SSH often, and especially if you have a passphrase on your private key. You can use ssh-add -l to see a list of the fingerprints of the keys that ssh-agent already knows about. (You will not be able to see the keys themselves - that would defeat the purpose of a secure agent.)

    As for why the EC2 isn't working... well, there isn't really enough information here, but: