如何在没有PEM密钥的情况下进入EC2实例?

时间:2016-09-29 22:38:04

标签: linux amazon-web-services ssh amazon-ec2

我创建了一个亚马逊Ec2实例,我正在尝试从本地计算机进入服务器。我可以使用PEM密钥执行此操作,但即使将本地计算机的公钥添加到授权密钥后,如果没有它,我也无法登录。它只是告诉我"权限被拒绝(公钥)。"这是痕迹。 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 个答案:

答案 0 :(得分:4)

在ssh期间,您需要ssh-agent来提供PEM文件。

首先,启动ssh-agent:

eval `ssh-agent -s`

然后将PEM密钥添加到代理

ssh-add <pem-key>

现在你可以在不提供PEM的情况下使用ssh。

答案 1 :(得分:2)

您可以将EC2 pem键添加到ssh

ssh-add ~/.ssh/key_pair.pem
相关问题