簡體   English   中英

嘗試通過SSH進入Amazon EC2時出現“權限被拒絕(公鑰)。”

[英]“Permission denied (publickey).” while trying to SSH into Amazon EC2

我在AWS上安裝了iPython,可以很好地通過瀏覽器訪問它。 但是,當我嘗試SSH到EC2實例時,出現以下錯誤:

Permission denied (publickey).

我嘗試使用現有的.pem密鑰,以及通過生成新密鑰,仍然沒有任何效果。 這些是我遵循的步驟:

  1. $ chmod 700〜/ .ssh
  2. cp〜/ desktop / aws / ipython.pem〜/ .ssh / ipython.pem
  3. chmod 600〜/ .ssh / ipython.pem
  4. ssh -i〜/ .ssh / ipython.pem ubuntu@50.174.xx.xx

在運行ssh命令“ ssh -i〜/ .ssh / ipython.pem ubuntu@50.174.xx.xx -v”時,我得到以下響應:

OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data /Users/coffeeman/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 20: Applying options for *
debug1: /etc/ssh/ssh_config line 102: Applying options for *
debug1: Connecting to 50.174.xx.xx [50.174.xx.xx] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /Users/coffeeman/.ssh/ipython.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/coffeeman/.ssh/ipython.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.6
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.6 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to 50.174.xx.xx:22 as 'ubuntu'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client chacha20-poly1305@openssh.com <implicit> none
debug1: kex: client->server chacha20-poly1305@openssh.com <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:uBRsbvwsIcqNN7vUfzpIXd6n7W5cpyGyU0DutxEHJE8E
debug1: Host '50.174.xx.xx' is known and matches the ECDSA host key.
debug1: Found key in /Users/coffeeman/.ssh/known_hosts:10
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/coffeeman/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/coffeeman/.ssh/ipython.pem
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

我究竟做錯了什么?

看來您沒有使用此密鑰創建EC2實例。 這是怎么做的

  • 轉到EC2控制台
  • 單擊Launch an instance ,然后選擇您的操作系統,實例類型等。
  • 您將轉到此窗口

在此處輸入圖片說明

  • 從選項列表中選擇“ Create a new key pair ”並為其命名,例如ipython
  • 點擊Download keypair
  • 將此存儲在〜/ .ssh / ipython.pem中
  • 使用SSH通過SSH連接到您的實例

    ssh -i ~/.ssh/ipython.pem your-ip

而且一切都應該沒問題! :)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM