2013-06-04 233 views
3

我一直在Win7上通過SSH訪問我的EC2實例。我不想在Ubuntu 12.04上的另一臺PC上使用ssh,得到「Permission denied(publickey)」。錯誤。我一直在尋找這個問題,並嘗試以下方法:ssh - 亞馬遜EC2上的權限被拒絕(publickey)

  • 刪除現有密鑰並在EC2儀表板上創建/下載新密鑰。
  • 將新密鑰放置在我的〜/ .ssh文件夾中。
  • 改變了密鑰的訪問權限與此命令(也試過400):

    搭配chmod 600的〜/ .ssh/leno.pem

  • 改變了的.ssh文件夾的與此有關的訪問權限命令(也試過700):

    搭配chmod 755的〜/ .ssh

  • 試圖這樣做,以及:

    附加的ssh 〜/ .ssh/leno.pem

沒有運氣。當我嘗試運行以下命令:

ssh -vvv -i ~/.ssh/leno.pem [email protected] 

我得到這個消息:

OpenSSH_5.9p1 Debian-5ubuntu1, OpenSSL 1.0.1 14 Mar 2012 
debug1: Reading configuration data /etc/ssh/ssh_config 
debug1: /etc/ssh/ssh_config line 19: Applying options for * 
debug2: ssh_connect: needpriv 0 
debug1: Connecting to ec2-50-19-199-128.compute-1.amazonaws.com [50.19.199.128] port 22. 
debug1: Connection established. 
debug3: Incorrect RSA1 identifier 
debug3: Could not load "/home/murat/.ssh/leno.pem" as a RSA1 public key 
debug1: identity file /home/murat/.ssh/leno.pem type -1 
debug1: identity file /home/murat/.ssh/leno.pem-cert type -1 
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.5p1 Debian-4ubuntu6 
debug1: match: OpenSSH_5.5p1 Debian-4ubuntu6 pat OpenSSH* 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1 
debug2: fd 3 setting O_NONBLOCK 
debug3: load_hostkeys: loading entries for host "ec2-50-19-199-128.compute-1.amazonaws.com" from file "/home/murat/.ssh/known_hosts" 
debug3: load_hostkeys: found key type RSA in file /home/murat/.ssh/known_hosts:1 
debug3: load_hostkeys: loaded 1 keys 
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],ssh-rsa 
debug1: SSH2_MSG_KEXINIT sent 
debug1: SSH2_MSG_KEXINIT received 
debug2: kex_parse_kexinit: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 
debug2: kex_parse_kexinit: [email protected],[email protected],ssh-rsa,[email protected],[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-dss 
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] 
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] 
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 
debug2: kex_parse_kexinit: none,[email protected],zlib 
debug2: kex_parse_kexinit: none,[email protected],zlib 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1 
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss 
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] 
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected] 
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96 
debug2: kex_parse_kexinit: none,[email protected] 
debug2: kex_parse_kexinit: none,[email protected] 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: mac_setup: found hmac-md5 
debug1: kex: server->client aes128-ctr hmac-md5 none 
debug2: mac_setup: found hmac-md5 
debug1: kex: client->server aes128-ctr hmac-md5 none 
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent 
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP 
debug2: dh_gen_key: priv key bits set: 142/256 
debug2: bits set: 534/1024 
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent 
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY 
debug1: Server host key: RSA c4:de:26:09:64:6f:7c:48:6b:2b:ef:8c:c5:b7:cc:1f 
debug3: load_hostkeys: loading entries for host "ec2-50-19-199-128.compute-1.amazonaws.com" from file "/home/murat/.ssh/known_hosts" 
debug3: load_hostkeys: found key type RSA in file /home/murat/.ssh/known_hosts:1 
debug3: load_hostkeys: loaded 1 keys 
debug3: load_hostkeys: loading entries for host "50.19.199.128" from file "/home/murat/.ssh/known_hosts" 
debug3: load_hostkeys: found key type RSA in file /home/murat/.ssh/known_hosts:2 
debug3: load_hostkeys: loaded 1 keys 
debug1: Host 'ec2-50-19-199-128.compute-1.amazonaws.com' is known and matches the RSA host key. 
debug1: Found key in /home/murat/.ssh/known_hosts:1 
debug2: bits set: 514/1024 
debug1: ssh_rsa_verify: signature correct 
debug2: kex_derive_keys 
debug2: set_newkeys: mode 1 
debug1: SSH2_MSG_NEWKEYS sent 
debug1: expecting SSH2_MSG_NEWKEYS 
debug2: set_newkeys: mode 0 
debug1: SSH2_MSG_NEWKEYS received 
debug1: Roaming not allowed by server 
debug1: SSH2_MSG_SERVICE_REQUEST sent 
debug2: service_accept: ssh-userauth 
debug1: SSH2_MSG_SERVICE_ACCEPT received 
debug2: key: leno.pem (0x7feb7db9aa10) 
debug2: key: /home/murat/.ssh/leno.pem ((nil)) 
debug1: Authentications that can continue: publickey 
debug3: start over, passed a different list publickey 
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password 
debug3: authmethod_lookup publickey 
debug3: remaining preferred: keyboard-interactive,password 
debug3: authmethod_is_enabled publickey 
debug1: Next authentication method: publickey 
debug1: Offering RSA public key: leno.pem 
debug3: send_pubkey_test 
debug2: we sent a publickey packet, wait for reply 
debug1: Authentications that can continue: publickey 
debug1: Trying private key: /home/murat/.ssh/leno.pem 
debug1: read PEM private key done: type RSA 
debug3: sign_and_send_pubkey: RSA ab:3a:89:be:34:43:5a:40:5f:8a:0c:ba:5d:33:bd:cb 
debug2: we sent a publickey packet, wait for reply 
debug1: Authentications that can continue: publickey 
debug2: we did not send a packet, disable method 
debug1: No more authentication methods to try. 
Permission denied (publickey). 

如何通過SSH訪問我的EC2 insance?我究竟做錯了什麼?

回答

6

當你這樣做:

刪除現有密鑰和創建/下載的EC2 儀表盤一個新的。

您不會更改現有實例上的密鑰。你所要做的就是創建一個可以分配給新啓動的實例的新密鑰。

您正在連接到實例並且它正在響應。當您收到此錯誤時,意味着您要連接的用戶不存在,或者您的公鑰未安裝在該用戶authorized_keys文件中。

+0

謝謝。我能夠使用原始密鑰進行連接。 – boomslang

+0

那麼如何安裝它? –

+0

@KinnardHockenhull每個用戶在主目錄的'.ssh'文件夾中都有自己的'authorized_keys'文件。文件的格式非常簡單,每行只有一個公鑰。如果用戶沒有它,您可以創建它,但它必須具有隻允許用戶訪問它的權限。 – datasage

相關問題