繁体   English   中英

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

[英]How to ssh into EC2 instance without PEM key?

我创建了一个Amazon Ec2实例,并且尝试从本地计算机ssh到服务器。 我可以使用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).

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

首先,启动ssh-agent:

eval `ssh-agent -s`

然后将您的PEM密钥添加到代理

ssh-add <pem-key>

现在,您无需提供PEM就可以ssh。

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

ssh-add ~/.ssh/key_pair.pem

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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