2011-04-12 224 views
2

我花了將近24小時試圖弄清楚我做錯了什麼,但我無法弄清楚這一點。開始覺得我的本地設置有問題。無法SSH進入Amazon EC2實例

  • 我已確認於chmod 400埃裏克 - keypair.pem
  • 我已經存儲埃裏克 - keypair.pem在我的用戶的.ssh文件夾,遷至其他id_rsa文件,只是讓他們不這樣做干擾(試圖刪除任何變量)
  • EC2實例安全具有SSH啓用

這裏的響應

$ ssh -v -v -i erik-keypair.pem [email protected] 
OpenSSH_5.2p1, OpenSSL 0.9.8l 5 Nov 2009 
debug1: Reading configuration data /etc/ssh_config 
debug2: ssh_connect: needpriv 0 
debug1: Connecting to ec2-XX-XX-XX-XXX.compute-1.amazonaws.com [XX.XX.XX.XXX] port 22. 
debug1: Connection established. 
debug2: key_type_from_name: unknown key type '-----BEGIN' 
debug2: key_type_from_name: unknown key type '-----END' 
debug1: identity file erik-keypair.pem type -1 
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-5ubuntu1 
debug1: match: OpenSSH_5.1p1 Debian-5ubuntu1 pat OpenSSH* 
debug1: Enabling compatibility mode for protocol 2.0 
debug1: Local version string SSH-2.0-OpenSSH_5.2 
debug2: fd 3 setting O_NONBLOCK 
debug1: SSH2_MSG_KEXINIT sent 
debug1: SSH2_MSG_KEXINIT received 
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],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-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,[email protected],aes128-ctr,aes192-ctr,aes256-ctr 
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,[email protected],aes128-ctr,aes192-ctr,aes256-ctr 
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: 124/256 
debug2: bits set: 502/1024 
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent 
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY 
debug1: Host 'ec2-XX-XX-XX-XXX.compute-1.amazonaws.com' is known and matches the RSA host key. 
debug1: Found key in /Users/erik/.ssh/known_hosts:1 
debug2: bits set: 523/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: SSH2_MSG_SERVICE_REQUEST sent 
debug2: service_accept: ssh-userauth 
debug1: SSH2_MSG_SERVICE_ACCEPT received 
debug2: key: erik-keypair.pem (0x0) 
debug1: Authentications that can continue: publickey 
debug1: Next authentication method: publickey 
debug1: Trying private key: erik-keypair.pem 
debug1: read PEM private key done: type RSA 
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). 

李四有人發現我做錯了什麼?

+0

我有完全相同的問題。我有一個EC2實例,我重啓了它(由於AWS硬件問題),當實例回來時,我無法通過ssh連接到它,並且我得到與Erik相同的錯誤。任何想法?到目前爲止,我必須創建一個新實例,將舊卷連接到它,將這些文件複製到實例並重新配置所有內容。整個過程非常煩人和昂貴(2個句子,而不是一個,快照,2個卷,而不是一個)。任何想法解決它? – 2012-06-13 21:37:19

回答

2

Rodney Quillo的答案很可能是正確的。我會通過說官方的Ubuntu發行版也有默認用戶作爲ubuntu來擴展它。

+0

Rodney和Sarge都是正確的,因爲有一個自定義的默認用戶名。謝謝大家 – 2011-04-12 23:53:55

0

如果我沒有弄錯,你應該使用ec2-user而不是root。

+0

使用$ ssh -v -v -i erik-keypair.pem的相同響應[email protected] – 2011-04-12 13:18:54

+4

如果您使用alestic.com的ubuntu AMI,請使用Ubuntu的用戶。 – 2011-04-12 13:49:43

0

我添加了這個答案,以防其他人有同樣的問題。我需要我的私鑰才能擁有.pem擴展名。沒有擴展名導致我的問題。

0

你確定你的Amazon EC2實例是SUSE Linux th螞蟻爲什麼使用'root'用戶。檢查您創建的實例類型。用戶depnds的類型EC2實例的

細節

操作系統類型---------- USENAME

  • Linux的亞馬遜EC2 ---------- -user
  • RHEL5 ---------- EC2用戶/ EC2用戶
  • Ubuntu的---------- ubuntu的
  • SUSE Linux的------- --- root

進一步的細節在 http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html