首页 文章

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

提问于
浏览
0

我创建了一个亚马逊Ec2实例,我正试图从我的本地机器ssh到服务器 . 我可以使用PEM密钥执行此操作,但即使将本地计算机的公钥添加到授权密钥后,如果没有它,我也无法登录 . 它只是告诉我"Permission denied (publickey)."这是跟踪 . 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 回答

  • 2

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

    首先,启动ssh-agent:

    eval `ssh-agent -s`
    

    然后将PEM密钥添加到代理

    ssh-add <pem-key>
    

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

  • 3

    您可以将EC2 pem键添加到ssh

    ssh-add ~/.ssh/key_pair.pem
    

相关问题