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

Joe*_*era 2 linux ssh amazon-ec2 amazon-web-services

我创建了一个 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).

hel*_*loV 5

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

首先,启动 ssh-agent:

eval `ssh-agent -s`
Run Code Online (Sandbox Code Playgroud)

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

ssh-add <pem-key>
Run Code Online (Sandbox Code Playgroud)

现在您无需提供 PEM 即可 ssh。