Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I created a new instance (tiny, 64 bit AMI linux from Amazon) Created a new key pair called "mir". I downloaded mir.pem and put it in my ~/.ssh folder. I even did ssh-add mir.pem.

Then I tried to ssh ubuntu@public_DNS_from_amazon

Why doesn't it work!?

share|improve this question
what does ssh -v say ? – Iain Jan 27 '11 at 21:06
Also, can you do a telnet public_DNS_from_amazon 22? This would rule out the firewall. – Andrew M. Jan 28 '11 at 2:07
I'ld avoid telnet and use nmap for checking open ports: nmap -PN public_DNS_from_amazon -p 22. (-PN in case the firewall blocks ping requests) – Lekensteyn Feb 12 '11 at 11:00
@Lekensteyn, there is absolutely no reason to avoid a telnet client in this case, it's perfectly fit for the job of checking ssh ports given you'll get cleartext info back in most cases. Nmap is (way) more rarely installed than telnet. – Shadok Nov 22 '11 at 15:30
possible duplicate of… Answer that worked for me was that the default installation firewall is fully locked down as per this answer – Richard Le Mesurier Jan 26 '12 at 11:34

Try ssh -i your-private.key, instead of ssh-adding the key.

Oh, and make sure you allowed TCP port 22 through the Security Group.

share|improve this answer

Does the security group (firewall configuration) allow SSH access?

More specifically - on the AWS management console page, select Security Groups in the left panel (towards the bottom) On the bottom-right panel, select "Inbound" tab, and make sure "Custom TCP rule" is selected. Enter 22 for the port number, click the "Add rule" button, then the "apply rule changes" button. No need to restart or reboot your instance, just need to enable TCP port 22 inbound

share|improve this answer
This answer did the trick for me. Also, since my instance run Ubuntu replace 'root' with ubuntu. Here's the line I connect with from the terminal: ssh -i ec2vpnkey.pem – user128280 Jul 14 '12 at 4:55

Try using either root or ec2-user as the username.

share|improve this answer

You need to open the ssh access to you instances with a ec2-authorize default -p 22 command. Have you done this?

share|improve this answer

This has been happening to me on some of my EC2 boxes. In general, it appears that if a process is taking all the processor or is behaving badly and you get disconnected, SSH might not be able to pick up when you try to reconnect. Rebooting the box through AWS console often helps.

share|improve this answer

It is also possible to launch an instance without associating it with a keypair. You might double check that when you launched your instance, you did so with the keypair you intended. If the instance launched with the wrong keypair, you'll need to relaunch your instance.

share|improve this answer


ssh -i ~/.ssh/mir.pem

where the x's are your public ip

share|improve this answer

To login to your AMI box you use the ec2-user. This means you would use the following to login: ssh -i mir.pem ec2-user@public_dns to login.

share|improve this answer

protected by EEAA Jul 14 '12 at 5:18

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.