2
votes

I have created an amazon Ec2 instance and I am trying to ssh into the server from my local machine. I can do so with the PEM key but even after adding my local machine's public key to the authorized keys, I cannot login without it. It just tells me "Permission denied (publickey)." Here is the trace. debug3: remaining preferred: keyboard-interactive,password debug3: authmethod_is_enabled publickey debug1: Next authentication method: publickey debug1: Offering RSA public key: /Users/joelscalera/.ssh/id_rsa debug3: send_pubkey_test debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey debug1: Trying private key: /var/root/.ssh/id_rsa debug3: no such identity: /var/root/.ssh/id_rsa: No such file or directory debug1: Trying private key: /var/root/.ssh/id_dsa debug3: no such identity: /var/root/.ssh/id_dsa: No such file or directory debug1: Trying private key: /var/root/.ssh/id_ecdsa debug3: no such identity: /var/root/.ssh/id_ecdsa: No such file or directory debug1: Trying private key: /var/root/.ssh/id_ed25519 debug3: no such identity: /var/root/.ssh/id_ed25519: No such file or directory debug2: we did not send a packet, disable method debug1: No more authentication methods to try. Permission denied (publickey).

2
Please note that Stackoverflow is for programming related questions only. Please review the help center for what topics can be asked here. This question may be appropriate on other SE sites such as Superuser. Check their help first to see if the question belongs there and if so you can click the "flag" link and select "in need of moderator attention" to request migration there.kaylum

2 Answers

5
votes

You need ssh-agent to supply your PEM file during ssh.

First, start the ssh-agent:

eval `ssh-agent -s`

Then add you PEM key to agent

ssh-add <pem-key>

Now you can ssh without supplying PEM.

2
votes

You can add EC2 pem key to ssh

ssh-add ~/.ssh/key_pair.pem