簡體   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