If you are getting a connection closed on port 22 when trying to connect to Amazon AWS EC2 server via ssh, the chances are the user name you are using is wrong. If you are following the instructions at: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html for the first time and you are confused at:
then you are not alone. You will have to change the command to refer to your own keypair.pem file. This part is easy. The “ec2-user” is valid for Fedora, RHEL and SUSE. If you are using Ubuntu, you’ll have to change the user to ubuntu. The full details are covered here.
The funky IP address at the end there can be copied from your dashboard. A screenshot would have saved me a bit of time too!
Note that this is a dynamic IP address allocation so if you terminate this instance and create a new one, this will change.