3
votes

I'm Using AWS - Amazon Web Services and running commands from MAC Terminal

http://ec2-52-xx-x-xx.us-west-2.compute.amazonaws.com

But I am getting this error :

Gateway Timeout: can't connect to remote host

I'm unable to access the site anymore because of this error there is a security group applied to this instance and port 22 for ssh is listed under this security group

6
I think you're saying that you cannot access the host over HTTP. Can you SSH to it and find out if a web server is actually running? Or use the AWS console to stop/start it to see if a reboot fixes it?jarmod
I tried to shh to it and is sys: ssh: Could not resolve hostname i: nodename nor servname provided, or not knownNadosh Al-Ghamdi
That's an indication that DNS resolution has failed. Check the host name (whatever ec2-52-xx-x-xx.us-west-2.compute.amazonaws.com is in reality). Are you sure that your EC2 instance is actually running and actually has that assigned public DNS name?jarmod

6 Answers

3
votes

Check the security group for this instance and try telnet IP <allow inbound port> . If the telnet is happening on any of these ports this means connectivity is there.

Now comes ssh, by default ssh is on port 22, which as per you already allowed in security group. So you need to check if anyone has changed the sshd_config file and changed the ports?

1
votes

port 22 for ssh is listed under this security group

This does not imply anything. Which are the IP addresses allowed to access? Also, check your dns name isn't changed as suggested by jarmod.

1
votes

Simply put, an inbound firewall protects the network against incoming traffic from the internet or other network segments, namely disallowed connections, malware and denial-of-service attacks. An outbound firewall protects against outgoing traffic originating inside an enterprise network.

0
votes

Are you sure that the host is actually still named ec2-52-xx-x-xx.us-west-2.compute.amazonaws.com? Each time you stop and restart an Amazon EC2 instance, the public DNS name will change. Double check it in the AWS console.

0
votes

Check both incoming and outgoing rules for port 22, also try with the allocated IP4

0
votes
To connect using the SSH, ssh should be installed correctly on your machine

just type **"SSH"** if something like this comes up that means your machine has ssh


*usage: ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
           [-D [bind_address:]port] [-E log_file] [-e escape_char]
           [-F configfile] [-I pkcs11] [-i identity_file]
           [-J [user@]host[:port]] [-L address] [-l login_name] [-m mac_spec]
           [-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address]
           [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]
           [user@]hostname [command]*

Mostly **Linux and macOS X** have already installed if not then go to the
[here][1]  


For **Windows Server** 2019 and Windows 10 [Openssh in Windows][2]


The first check is there any problem with your ssh is allowed from the security group of that particular instance 


like is it allowing to connect from ssh or not

once that is confirmed you have to enter the correct syntax to connect the AWS instance 

Using Public DNS that is available under the running instance

**ssh -i /path/my-key-pair.pem my-instance-user-name@my-instance-public-dns-name**

Using ipv6 similarly, ipv4 can be done

**ssh -i /path/my-key-pair.pem my-instance-user-name@my-instance-IPv6-address**

in place of **my-instance-user-name** you can through documentation provided by AWs[1]


  [1]: http://www.openssh.com
  [2]: https://docs.microsoft.com/en-us/windows-server/administration/openssh/openssh_overview