无法SSH到Amazon EC2实例

无法SSH到Amazon EC2实例,ssh,amazon-ec2,Ssh,Amazon Ec2,我花了将近24小时试图找出我做错了什么,但我无法找出这一点。开始觉得我的本地设置有问题 我已确保chmod 400 erik-keypair.pem 我已将erik-keypair.pem存储在我的user.ssh文件夹中,并重新定位了其他id_rsa文件,以便它们不会干扰(尝试删除任何变量) Ec2实例安全性已启用ssh 以下是答案 $ ssh -v -v -i erik-keypair.pem root@ec2-XX-XX-XX-XXX.compute-1.amazonaws.com O

我花了将近24小时试图找出我做错了什么,但我无法找出这一点。开始觉得我的本地设置有问题

  • 我已确保chmod 400 erik-keypair.pem
  • 我已将erik-keypair.pem存储在我的user.ssh文件夹中,并重新定位了其他id_rsa文件,以便它们不会干扰(尝试删除任何变量)
  • Ec2实例安全性已启用ssh
以下是答案

$ ssh -v -v -i erik-keypair.pem root@ec2-XX-XX-XX-XXX.compute-1.amazonaws.com
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,rijndael-cbc@lysator.liu.se
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,rijndael-cbc@lysator.liu.se
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com,zlib
debug2: kex_parse_kexinit: none,zlib@openssh.com,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,rijndael-cbc@lysator.liu.se,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,rijndael-cbc@lysator.liu.se,aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,zlib@openssh.com
debug2: kex_parse_kexinit: none,zlib@openssh.com
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).
$ssh-v-v-i erik-keypair.pemroot@ec2-XX-XX-XX-XXX.compute-1.amazonaws.com
OpenSSH_5.2p1、OpenSSL 0.9.8l 2009年11月5日
debug1:读取配置数据/etc/ssh\u config
debug2:ssh\u connect:needpriv 0
debug1:连接到ec2-XX-XX-XX-XXX.compute-1.amazonaws.com[XX.XX.XX.XXX]端口22。
debug1:已建立连接。
debug2:密钥类型\u from\u name:未知密钥类型'----BEGIN'
debug2:密钥类型\u from\u name:未知密钥类型'----END'
debug1:标识文件erik-keypair.pem类型-1
debug1:远程协议版本2.0,远程软件版本OpenSSH_5.1p1 Debian-5ubuntu1
debug1:match:OpenSSH_5.1p1 Debian-5ubuntu1 pat OpenSSH*
debug1:启用协议2.0的兼容模式
debug1:本地版本字符串SSH-2.0-OpenSSH_5.2
调试2:fd 3设置O_非块
debug1:SSH2\u MSG\u KEXINIT已发送
debug1:SSH2\u MSG\u KEXINIT已收到
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、河豚cbc、cast128 cbc、aes192 cbc、aes256 cbc、arcfour、rijndael-cbc@lysator.liu.se
debug2:kex_parse_kexinit:aes128 ctr、aes192 ctr、aes256 ctr、arcfour256、arcfour128、aes128 cbc、3des cbc、河豚cbc、cast128 cbc、aes192 cbc、aes256 cbc、arcfour、rijndael-cbc@lysator.liu.se
debug2:kex_parse_kexinit:hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2:kex_parse_kexinit:hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2:kex_parse_kexinit:none,zlib@openssh.com,zlib
debug2:kex_parse_kexinit:none,zlib@openssh.com,zlib
debug2:kex_parse_kexinit:
debug2:kex_parse_kexinit:
debug2:kex_parse_kexinit:first_kex_跟随0
debug2:kex_parse_kexinit:保留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、河豚cbc、cast128 cbc、arcfour128、arcfour256、arcfour、aes192 cbc、aes256 cbc、rijndael-cbc@lysator.liu.se,aes128中心,aes192中心,aes256中心
debug2:kex_parse_kexinit:aes128 cbc、3des cbc、河豚cbc、cast128 cbc、arcfour128、arcfour256、arcfour、aes192 cbc、aes256 cbc、rijndael-cbc@lysator.liu.se,aes128中心,aes192中心,aes256中心
debug2:kex_parse_kexinit:hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2:kex_parse_kexinit:hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160,hmac-ripemd160@openssh.com,hmac-sha1-96,hmac-md5-96
debug2:kex_parse_kexinit:none,zlib@openssh.com
debug2:kex_parse_kexinit:none,zlib@openssh.com
debug2:kex_parse_kexinit:
debug2:kex_parse_kexinit:
debug2:kex_parse_kexinit:first_kex_跟随0
debug2:kex_parse_kexinit:保留0
debug2:mac_安装程序:找到hmac-md5
debug1:kex:server->client aes128 ctr hmac-md5无
debug2:mac_安装程序:找到hmac-md5
debug1:kex:客户端->服务器aes128 ctr hmac-md5无

debug1:SSH2\u MSG\u KEX\u DH\u GEX\u请求(1024如果我没有弄错的话,你应该使用ec2用户而不是root用户。

罗德尼·奎洛的答案很可能是正确的。我会扩展它,说官方Ubuntu发行版也有默认用户作为Ubuntu。

我正在添加这个答案,以防其他人有同样的问题。我需要我的私钥来拥有.pem扩展。否t使用该扩展导致了我的问题。

您确定您的Amazon EC2实例是SUSE Linux吗?t您为什么使用“root”用户。请检查您创建的实例类型。用户会根据EC2实例的类型进行说明

细节

操作系统类型usename

AmazonLinuxEC2用户 RHEL5 ec2用户/ec2用户 Ubuntu SUSE Linux根目录

详情请参阅

您确定您的Amazon EC2实例是SUSE Linux吗?这是您使用“root”用户的原因。请检查您创建的实例类型。用户会根据EC2实例的类型进行说明

细节

操作系统类型-----------usename

  • 亚马逊Linux------ec2用户
  • RHEL5------ec2用户/ec2用户
  • Ubuntu------Ubuntu
  • SUSE Linux------根目录
详情请参阅

使用$ssh-v-v-i erik-keypair.pem ec2进行相同的响应-user@ec2-XX-XX-XX-XXX.compute-1.amazonaws.com如果您使用alestic.com上的ubuntu AMI,请使用ubuntu用户。Rodney和Sarge都是正确的,因为有一个自定义默认用户名。谢谢,我有完全相同的问题。我有一个EC2实例,我重新启动了它(由于AWS硬件问题)当实例返回时,我无法通过ssh连接到它,我得到了与Erik相同的错误。有什么想法吗?到目前为止,我必须创建一个新实例,将旧卷连接到它,将文件复制到实例并重新配置所有内容。整个过程非常烦人且昂贵(两个指令而不是一个,一个快照,两个卷而不是一个)。有没有办法修复它?