连接已建立。Ubuntu ec2 实例的 ssh 登录问题仍然存在

连接已建立。Ubuntu ec2 实例的 ssh 登录问题仍然存在

我无法登录到我的服务器(ec2 实例)。在此之前我可以登录。服务器或安全组没有发生任何变化!这个问题是来自 aws 方面吗?是否突然发生有时您无法连接到 ec2 实例并需要重新启动,或者这是一个安全漏洞,因此有人可能篡改了服务器上的密钥?

ashish@ashishk:~/MyScripts$ ./test.ssh 

OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014

debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to test.ige.com [ipxxxxx] port 22.
debug1: Connection established.
debug1: identity file /home/ashish/Keys/igepune.pem type -1
debug1: identity file /home/ashish/Keys/igepune.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2

我的登录脚本:

ashish@ashishk:~/MyScripts$ cat ./test.ssh 
ssh ubunt@ipxxxxx -v -i ~/Keys/igepune.pem 

输出-vvv

ashish@ashishk:~/MyScripts$ ./test.ssh 

OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
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 test.ige.com [ipxxxx] port 22.
debug1: Connection established.
debug3: Incorrect RSA1 identifier
debug3: Could not load "/home/ashish/Keys/igepune.pem" as a RSA1 public key
debug1: identity file /home/ashish/Keys/igepune.pem type -1
debug1: identity file /home/ashish/Keys/igepune.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2

**ashish@ashishk:~/MyScripts$ ll /home/ashish/Keys/igepune.pem**

-r-------- 1 ashish ashish 1679 Apr 21 18:56 /home/ashish/Keys/igepune.pem

我怀疑亚马逊是否会在一定时间后使 pem 密钥过期?

答案1

从您的调试输出:

debug1: identity file /home/ashish/Keys/igepune.pem type -1
debug1: identity file /home/ashish/Keys/igepune.pem-cert type -1

“身份文件”行末尾的“-1”表示您的 SSH 客户端找不到要使用的文件。

另外,您可以使用 -vvvv 来代替 ssh 的 -v 参数,使其更加详细。

答案2

实际上,您可能需要仔细检查要连接的服务器的 IP 地址。如果您使用弹性 IP 重新启动 AWS EC2 实例,则公共 IP 地址会发生变化,因此您可能无法登录。

另一件要查看的事情是您的 IP 地址是否已更改。如果您已设置安全规则来限制对您的 IP 地址的访问,那么当您的 IP 地址发生更改时,您将无法登录。

答案3

重启后我就可以通过 ssh 连接到服务器了!

这是因为这个 i/o 问题!这是亚马逊的 ec2 问题,所以有时存在 i/o 问题,导致找不到服务器上的密钥!只需重新启动即可解决问题!

感谢大家的帮助!

相关内容