简体   繁体   中英

SSH hangs when attempting to connect to amazon AWS EC2 instance

Brand new to AWS. I was able to ssh to my EC2 instance fine yesterday, but today SSH hangs with this (verbose) output:

-> 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. I have a security rule allowing ssh to port 22 from anywhere.

I can ping the instance and telnet to port 22 fine.

You may also look into the monitoring section of the ec2 instance for the CPU usage. If the CPU usage was 100% this may cause the problem. Since you are able to ssh now, check for the free disk space as well.

I had to paste the contents of my public key, at ~/.ssh/id_rsa.pub , to Key Pairs under ymy EC2 Dashboard. 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).

The same thing happened to my instance, I could not ssh into it and my application running on it was unreachable. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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