简体   繁体   English

尝试连接到亚马逊 AWS EC2 实例时 SSH 挂起

[英]SSH hangs when attempting to connect to amazon AWS EC2 instance

Brand new to AWS.全新的 AWS。 I was able to ssh to my EC2 instance fine yesterday, but today SSH hangs with this (verbose) output:昨天我能够很好地通过 ssh 连接到我的 EC2 实例,但今天 SSH 挂起这个(详细)输出:

-> ssh -vvv -i "x.pem" ec2-user@ec2-x-x-x-x.us-east-2.compute.amazonaws.com

OpenSSH_7.2p2 Ubuntu-4ubuntu2.4, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "ec2-x-x-x-x.us-east-2.compute.amazonaws.com" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to ec2-x-x-x-x.us-east-2.compute.amazonaws.com [18.191.133.22] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file x.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file x.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.4

I tried the suggestions here SSH hangs when connecting to Amazon EC2 instance but none worked.我尝试了此处的建议,连接到 Amazon EC2 实例时 SSH 挂起,但没有奏效。 I have a security rule allowing ssh to port 22 from anywhere.我有一个安全规则,允许 ssh 从任何地方访问 22 端口。

I can ping the instance and telnet to port 22 fine.我可以 ping 实例并 telnet 到端口 22 很好。

You may also look into the monitoring section of the ec2 instance for the CPU usage.您还可以查看 ec2 实例的监控部分以了解 CPU 使用情况。 If the CPU usage was 100% this may cause the problem.如果 CPU 使用率为 100%,这可能会导致问题。 Since you are able to ssh now, check for the free disk space as well.由于您现在可以 ssh,因此还要检查可用磁盘空间。

I had to paste the contents of my public key, at ~/.ssh/id_rsa.pub , to Key Pairs under ymy EC2 Dashboard.我必须将位于~/.ssh/id_rsa.pub内容粘贴到 ymy EC2 Dashboard 下的Key Pairs Then I used this key when creating a new AWS instance (I blew away my old instance--maybe there is a way to change the keys).然后我在创建一个新的 AWS 实例时使用了这个密钥(我吹走了我的旧实例——也许有一种方法可以更改密钥)。

The same thing happened to my instance, I could not ssh into it and my application running on it was unreachable.我的实例也发生了同样的事情,我无法通过 ssh 进入它,并且无法访问在它上面运行的应用程序。 In the console the instance status was "Running".在控制台中,实例状态为“正在运行”。 I am not sure what causes this, I eventually fixed it by just restarting the instance.我不确定是什么原因造成的,我最终通过重新启动实例来修复它。 It seems that ubuntu froze for some reasons.似乎 ubuntu 由于某些原因冻结了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM