22

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!?

  • 3
    what does ssh -v say ? – user9517 supports GoFundMonica Jan 27 '11 at 21:06
  • 2
    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
  • 1
    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
  • 2
    @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 serverfault.com/questions/245916/… Answer that worked for me was that the default installation firewall is fully locked down as per this answer serverfault.com/a/245917/108387 – Richard Le Mesurier Jan 26 '12 at 11:34
17

Try ssh ubuntu@your.host.name -i your-private.key, instead of ssh-adding the key.

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

  • The hint of adding the port 22 to the security group did the trick. I was already using ssh -i private_key – kisanme Jun 15 '17 at 11:35
7

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

  • 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 ubuntu@exxxxxxxxxx.compute-1.amazonaws.com – user128280 Jul 14 '12 at 4:55
  • this should be the accepted answer. key information here is that the field "source" is not sufficient to have the security group itself. Source must be 0.0.0.0/0 – roothahn Aug 13 '17 at 15:51
3

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

0

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

0

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.

0

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.

0

Try

ssh -i ~/.ssh/mir.pem ec2-user@xxx.xxx.xxx.xxx

where the x's are your public ip

0

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.

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