After creating a new instance, I am trying to access my instance like below:

ssh -i private_key.pem root@my_instance_public_domain

but the operation is timing out. I have updated the private key file permission using

chmod 400

and also edited default security group by adding a new in bound rule, selecting SSH and source Ip as

but getting port 22: Operation timed out.

What I am missing.

  • Is the ip you are connecting from If not you have to modify the security group. You must also ensure that the instance is part of your security group Jun 6, 2012 at 18:40
  • my ip is doest it mean "You must also ensure that the instance is part of your security group "?
    – arnold
    Jun 6, 2012 at 18:42
  • this just means you have to make sure that the instance must be assigned to your security group. Just to be sure must be your external ip address. Another problem (but unlikely problem if you use a provided AMI) may be that your instace has no ssh server running / has customized firewall rules. Jun 6, 2012 at 18:48
  • I have already added the instance under the security group it is default and in that security group I have set ssh using my ip
    – arnold
    Jun 6, 2012 at 18:53

3 Answers 3


Did you manage to resolve your ssh issue to your ec2 instance?

I also encountered ssh login issues while setting up my first ec2 instance.

Here was how I resolved my ssh login issue:

  • with your instance's security group, set your inbound SSH rule's Source IP to first, and make sure you can get a working connection with this setting. Once you have your ssh connection working, you can then tighten access by changing Source IP to the IP range of the machine you are logging in from. Note that if this machine has a non-static public IP, then you will frequently have to change the Source IP setting for your SSH rule.

  • I have noticed from my own experience that if I try to ssh to my new instance without waiting for its status checks to complete, I would encounter a ssh timeout issue. This was especially true for a newly created instances. In your AWS console, there should be a 'State' and 'Status Checks' column for each of your instance. Make sure the 'State' entry for your instance shows 'running' (with a green circle next to it), and the 'Status Checks' entry shows '2/2 checks passed' (with a green circle and white tick). This could take awhile at times - so go get some snacks, then come back and try logging in again.

  • I have found enabling ssh verbosity when helpful for debugging ssh issues too. Try this command to enable verbosity:

    ssh -vvv -i private_key.pem root@my_instance_public_domain

  • pinging your instance's public FQDN may also help, but make sure your instance's Security Group rules are set to allow ICMP traffic.

  • trying to telnet to port 22 of your instance's public FQDN may also help with troubleshooting. e.g.

    telnet my_instance_public_domain 22


If you're using a non-default VPC, then you also

need a route that sends all traffic destined outside the VPC ( to the Internet gateway for the VPC.


I had the same problem, Amazon has an actually pretty helpful troubleshooting guide here: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/TroubleshootingInstancesConnecting.html

My problem was that I created a few subnets for using them with the same VPC, but had no idea I have to connect the subnets to the VPC via route tables and had to add an internet gateway to each of the route tables.

  • Dear Downvoter: consider adding a comment if you think this answer can be improved?
    – frzsombor
    Oct 6, 2021 at 12:02
  • Welcome to the site, and thank you for your contribution. Although I'm not the downvoter, please keep in mind that your answer relies heavily on externally linked content. Link-only-answers are discouraged however as links may become defunct or the linked content change. Please consider summarizing the necessary steps for setting up the route in your post.
    – AdminBee
    Oct 6, 2021 at 13:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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