0

I have an ec2 instance on AWS that has an EIP associated and is accessible via SSH (usually). Not sure what changed between yesterday and today but now I cant SSH into the server directly from my PC. This is what happens:

  1. When I SSH to the server (say foo), I get:

    debug1: Connecting to foo [10.0.0.55] port 22. debug1: connect to address 10.0.0.55 port 22: Connection refused ssh: connect to host foo port 22: Connection refused

  2. When I run host foo, it resolves to the correct EIP and domain:

    foo.bar.net has address 34.204.x.x

I know one solution is to either add an entry into /etc/hosts or to adjust my ~/.ssh/config and add the .bar.net to the host's entry. I don't want to do either or. My question is, what can I do aside from these two solutions to make sure that SSH points to the EIP instead of it's internal IP? Just an FYI, my PC I am using is Mac OSX.

  • Perhaps see if your ssh key is still there (ls -al ~/.ssh) locally and whether t is still recognized by AWS ? – Cbhihe Jun 7 '17 at 16:10
  • One of the first things i checked.. its not a key issue – ryekayo Jun 7 '17 at 16:11
  • What is an "EIP"? External IP? And there is something wrong on your local computer if it is pointing to 10.0.0.55. What's at 10.0.0.55? What's in /etc/hosts? What happens when you try to SSH to your server's FQDN? – cutrightjm Jun 7 '17 at 18:47
  • EIP = elastic IP, and sorry but i wanted to give random IPs not the actual IPs – ryekayo Jun 7 '17 at 18:48
0

ssh doesn't "point to" anything, unless you specifically set that up in .ssh/config .

Also note that the host command specifically uses DNS to look up names, and will not check your /etc/hosts file.

Something in your machine's configuration is relating a host named "foo" to that IP address. Is it in your /etc/hosts file? Maybe your /etc/nsswitch.conf file is doing something unusual and pulling "foo" from an LDAP or NIS server?

What do you get if you ping foo or nc -v foo 22 ?

  • I ended up using HostName in my config so it can resolve correctly.. still remains a mystery.. i couldnt find anything that points to the wrong IP – ryekayo Jun 7 '17 at 18:47

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.