简体   繁体   中英

How to ssh into EC2 instance without PEM key?

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).

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.

您可以将EC2 pem密钥添加到ssh

ssh-add ~/.ssh/key_pair.pem

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM