Unable to SSH to my local computer from a remote EC2 instance

0

I'm able to connect to my EC2 instance from my local computer, but would like to access files on my computer from EC2. I have already generated a key pair on EC2 and added the public key to my authorized_keys file on my local computer. However, the following command fails:

ssh ec2-user@172.XX.X.XX

With the error:

ssh: connect to host 172.XX.X.XX port 22: Connection timed out

where the IP address is my computer's IP address. What am I missing?

I have been told about port forwarding my router, but I am not sure how to go about that.

Nole

Posted 2018-04-02T00:37:30.000

Reputation: 3

Is ssh ec2-user@172.XX.X.XX your connection to your local computer? Are you sure that 172.XX.X.XX is your public address? – JakeGould – 2018-04-02T00:55:16.103

The 172.XX.X.XX IP is what is shown when I go to System Preferences > Network on my Mac. In addition, when I go to System Preferences > Sharing, I have Remote Login set to On, and am told that I can access my computer remotely with ssh nole@172.XX.X.XX – Nole – 2018-04-02T01:10:13.653

“The 172.XX.X.XX IP is what is shown when I go to System Preferences > Network on my Mac” That is most likely your internal routed address since this typically start with 192, 172 and 10. To find your external addresses you need to go to to an external website like this one. You can try and see if that would work, but to be able to access your home system remotely some remote login capability would need to be active on your system (which you do) but also make sure your external IP address can route to your internal one.

– JakeGould – 2018-04-02T01:25:25.410

Also asked and answered but closed at https://stackoverflow.com/questions/49595737/unable-to-ssh-to-my-local-computer-from-ec2-instance

– dave_thompson_085 – 2018-04-02T07:42:41.090

Answers

0

172.x.x.x is an rfc1918 IP address. It is reserved for private local area networks.

You can find your external IP ( the IP of your home) by going to a website like whatsmyip.com or ipchicken.com.

You'll need to go into your router and set up port forwarding from the external IP and some port (pick one of the high numbered unprivileged ports. For example 30022. And forward that to your computers 172.x.x.x IP and port 22.

Then from your ec2 instance ssh to the external IP and port.

If you provide your router model we can help you set it up

Timmy Browne

Posted 2018-04-02T00:37:30.000

Reputation: 430

Thank you for your answer. I configured my router to open up port forwarding and was able connect from EC2 to my local computer. – Nole – 2018-04-02T05:31:50.750