Search code examples
amazon-web-servicesamazon-ec2ssh-tunnel

Why can't i SSH into my EC2 instance if my security group is allowing TCP on Port 22 and there is no Network Access Control List?


I have an ec2 instance that i want to use as an SSH tunnel for MySQL Workbench.

Its access is locked down to My IP, Port 22 for TCP traffic. There is no NACL.

I can start a session in Systems Manager Session Manager and see the instance is working and can ping public URLs.

The key pair is in the folder from where i am running the following command:

ssh -i "key-pair.pem" ec2-user@11.22.33.44 

However, the operation times out from my terminal and also when i try to connect via MySQL Workbench. Can anyone help?

If i add -vvv to the command i get the following output

debug1: Reading configuration data /Users/xxxx/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 47: Applying options for *
debug2: resolve_canonicalize: hostname 11.22.33.44 is address
debug2: ssh_connect_direct
debug1: Connecting to 11.22.33.44  [11.22.33.44] port 22.
debug1: connect to address 11.22.33.44 port 22: Operation timed out
ssh: connect to host 11.22.33.44 port 22: Operation timed out

Solution

  • The problem here was that my VPN was using a different IP to what the MyIP option in the security group was choosing so my requests were rejected at the security group level.