EC2重启后无法通过ssh访问

我通过SSH连接我的EC2实例,添加新的EBS卷后,通过'sudo shutdown -r now'重新启动机器,然后尝试使用follwing命令访问:

ssh -v -i primary_key.pem [email protected] 

这是重新调整如下:

 debug1: Reading configuration data /Users/caveman/.ssh/config debug1: Reading configuration data /etc/ssh_config debug1: Applying options for * debug1: Connecting to ec2-23-22-245-160.compute-1.amazonaws.com [23.22.245.160] port 22. debug1: Connection established. debug1: identity file primary_key.pem type -1 debug1: identity file primary_key.pem-cert type -1 debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1 debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 pat OpenSSH* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_5.6 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-ctr hmac-md5 none 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 debug1: SSH2_MSG_KEX_DH_GEX_INIT sent debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY debug1: Host 'ec2-23-22-245-160.compute-1.amazonaws.com' is known and matches the RSA host key. debug1: Found key in /Users/caveman/.ssh/known_hosts:31 debug1: ssh_rsa_verify: signature correct debug1: SSH2_MSG_NEWKEYS sent debug1: expecting SSH2_MSG_NEWKEYS debug1: SSH2_MSG_NEWKEYS received debug1: Roaming not allowed by server debug1: SSH2_MSG_SERVICE_REQUEST sent debug1: SSH2_MSG_SERVICE_ACCEPT received debug1: Authentications that can continue: publickey debug1: Next authentication method: publickey debug1: Trying private key: primary_key.pem debug1: read PEM private key done: type RSA debug1: Authentications that can continue: publickey debug1: No more authentication methods to try. Permission denied (publickey). 

什么是错的?我错过了什么?

该线

 debug1: Authentications that can continue: publickey 

表示您禁用了密码validation。 您只能使用公钥进行身份validation(同时拥有相应的私钥)。

连续两行

 debug1: read PEM private key done: type RSA debug1: Authentications that can continue: publickey 

表示您正在使用可以正常读取的RSA私钥,但是其公共对象无法通过服务器进行身份validation。

一些选项可以尝试:

  • 仔细检查你使用的是正确的钥匙。
  • 仔细检查用户名。 也许你在创build帐户时发生了错字,或者在复制密钥( ssh-copy-id )时使用了自己的用户名。
  • 如果以其他方式访问服务器,请recursion检查完整的~ubuntu/.ssh目录下的权限(和所有权!)。
  • 如果您没有在SSH守护程序中禁用PasswordAuthentication ,则可能表明密码已被重置为空或用户帐户被禁用( usermod -L )以进行login或过期。 尝试使用其他用户login(可能是root用户帐户)。
  • 如果您在SSH守护程序的configuration文件中禁用了PasswordAuthentication ,但在此之后没有重新启动它,那么更改可能只会在重新启动后变为活动状态。 请参阅下面的选项以了解如何解决此问题。
  • 您是否可以使用EC2中的控制面板直接访问文本控制台? 我不熟悉Amazon AWS,但我认为你应该有这个select。 然后,您应该能够使用控制台login来重置您的密码并通过SSH访问。
  • 尝试closures您的EC2实例并将存储设备连接到另一个实例。 安装它并执行手动密码恢复。 重新将其重新附加到原始实例,并且应该被修复。
  • 再次获得访问权限后,请检查您的服务器是否未被入侵。 仅在重新启动后触发的configuration更改可能表明它有。 我看到这发生在几台服务器上。