# ssh to dns server ends up in 127.0.0.1 [Solved]

## vespaman

I reinstalled my desktop, and have run into a problem that I don't understand. 

I have a server named 'xenon' which is dns. 

If I ping xenon, get what I wolud expect;

```
ata.

64 bytes from xenon (10.1.200.1): icmp_seq=1 ttl=64 time=0.161 ms

64 bytes from xenon (10.1.200.1): icmp_seq=2 ttl=64 time=0.221 ms

```

I can also browse to it, mount shares etc.

However, if I want to ssh into the same, I end up in localhost. 

```
ssh -v xenon

OpenSSH_7.2p2lpk, OpenSSL 1.0.2h  3 May 2016

debug1: Reading configuration data /etc/ssh/ssh_config

debug1: Connecting to xenon [127.0.0.1] port 22.

debug1: Connection established.

```

my /etc/resolv contains only has 

```
# Generated by net-scripts for interface eth0

nameserver 10.1.200.1

```

And there's nothing strange in the hosts file either.

I I ssh using ip address, it works as expected.

So why is this happening??Last edited by vespaman on Sat Jun 04, 2016 9:49 pm; edited 1 time in total

----------

## cboldt

What's in /etc/hosts?

----------

## vespaman

only 

127.0.0.1       localhost                                                                                                                            

::1             localhost6                                                                                                                           

10.1.200.50     hush hush.bxxxxs.com

----------

## Hu

Perhaps you have an ssh config option which sets the effective address of name xenon.  What is the output of grep -En '^[^#]' /etc/ssh/ssh_config ~/.ssh/config?

----------

## vespaman

This gives me;

```
grep -En '^[^#]' /etc/ssh/ssh_config ~/.ssh/config

/etc/ssh/ssh_config:53:SendEnv LANG LC_*

grep: /home/micke/.ssh/config: No such file or directory

```

----------

## cboldt

I think something on your DNS system is assigning 127.0.0.1 to xenon.  You say xenon is the DNS server, but you haven't described the DNS software that you have running on xenon.

I have no idea why ping would find the right address, and ssh not.

The file /etc/ssh/ssh_config  (which your ssh is referring to) allows configuration on a per-host basis, but I don't know that it is able to change the IP address of any host.

----------

## limn

If you don't already have it on your desktop you could install bind-tools and run nslookup.

----------

## vespaman

Weird!

Thanks Guys! Using nslookup showed xenon on two addresses. Turns out that xenon (with dnsmasq) had xenon as an alias for localhost in its hosts file.

But the weird thing is that I have not changed that box in years, and it has been, and was working on all other computers, even this desktop before reinstalling gentoo. 

And why only ssh?

The laptop next to it has the exact same version of ssh, ~arch and 64bit, yet it worked.

I would never had expected the server config... .  :Shocked: 

```
nslookup xenon

Server:         10.1.200.1

Address:        10.1.200.1#53

Name:   xenon

Address: 10.1.200.1

Name:   xenon

Address: 127.0.0.1
```

----------

## Hu

 *cboldt wrote:*   

> The file /etc/ssh/ssh_config  (which your ssh is referring to) allows configuration on a per-host basis, but I don't know that it is able to change the IP address of any host.

 The ssh directive HostName can override the address associated with a name.  It is intended for establishing nicknames for systems where the authoritative DNS has no name, the wrong IP address, or an inconvenient name.  See man ssh_config for usage details.  Using it does not technically change the IP address of the host, but it does change the target to which ssh will connect.

----------

## cboldt

 *Hu wrote:*   

>  *cboldt wrote:*   The file /etc/ssh/ssh_config  (which your ssh is referring to) allows configuration on a per-host basis, but I don't know that it is able to change the IP address of any host. The ssh directive HostName can override the address associated with a name.  It is intended for establishing nicknames for systems where the authoritative DNS has no name, the wrong IP address, or an inconvenient name.  See man ssh_config for usage details.  Using it does not technically change the IP address of the host, but it does change the target to which ssh will connect.

 

Now that you mention that, I actually use that, but for the purpose you mention, a nickname, not to override the IP address associated with a domainname.  It takes two lines in ssh_config (or equivalent) ...

```
Host            home

Hostname        domain.com
```

I agree with you, if the named "Host" was "xenon," and the "Hostname" was "localhost," then `ssh xenon` would effectively run `ssh localhost` instead.

Thanks much for the brief tutorial!  I wonder sometimes, how I can forget more than I learned.  Glad to see the OP found the problem, of course, and much enjoy the side lessons.

----------

