Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't SSH into EC2 from my mac but can from other devices

I am trying to connect into an EC2 instance (i am using a mac) which has a Security Group allowing all inbound traffic over ssh (port 22) but i'm unable to access. I'm having a little delay before getting an Operation timed out.

I already tried it over other devices such a raspberry pi and another macbook and the connection was successful. I got access to the raspberry pi over ssh and tried the connection to my EC2 from the terminal; thought my ssh client or the port status could be the issue but after doing this i'm not really sure if this is the case.

This is the message i get when trying to connect:

ssh: connect to host x.x.x.x port 22: Operation timed out

One thing I noticed is that I used a different .pem file which is supposed to not work for that instance and the error was the same, it looks like my Mac cannot reach it.

Things already verified:

  • Security Group allowing traffic over port 22.
  • Instance rebooted/recreated.
  • DNS and Public IP address changed after instance reboot.
  • SSH connection successful over other devices.
  • SSH connection to other devices from this mac successful.
  • Firewall turned off.
  • DNS flushed.
  • Ping performed with success.

Any help is really appreciated it.

-- UPDATE --

This issue rose in my work machine. Got a different laptop due to other issues and problem fixed, looks like it might have been something related to ports or some sort of configuration. Thought it was a problem with AWS but now it's working fine. Sadly I couldn't debug enough to know what the exact issue was. Thanks to everyone who helped out!

like image 877
Gustavo Mungarro Avatar asked Dec 01 '25 21:12

Gustavo Mungarro


1 Answers

It seems that you can remote by other devices and this issue is only still happening on your MAC. Try this on your MAC and try to remote again:

Flush your DNS

I don't know which Mac OS you are using so I put the link here: (https://help.dreamhost.com/hc/en-us/articles/214981288-Flushing-your-DNS-cache-in-Mac-OS-X-and-Linux)

If still cannot, you can try to open some protocol ports on that instances like:

ICMP, Echo Reply, ...

then try to reach by that protocol commands:

Ping, telnet, ...

If the result is cannot too, so it must be that your MAC cannot even reach to that instance network, then try to ensure that your MAC can reach the instance's network first.

like image 109
Binh Nguyen Avatar answered Dec 03 '25 14:12

Binh Nguyen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!