SSH ; can ssh IP, but cannot ssh to hostname

Issues related to configuring your network
Post Reply
jxl1145
Posts: 36
Joined: 2014/09/14 01:14:32

SSH ; can ssh IP, but cannot ssh to hostname

Post by jxl1145 » 2014/10/14 23:42:18

Hello,

I have a physical host centos:

I've got 4 kvm's.

I used hostnamectl set-hostname command to change all 4 kvm's: server1, server1, client1, client2
Verified new change via hostnamectl and hostname commands.
Default /etc/hosts was:
127.0.0.1 localhost.localdomain localhost
::1 localhost localhost.localdomain localhost6 localhost.localdomain6
below the 127.0.0.1 line I added:
192.168.122.xxx (xxx representing number of ifconfig IP to each of the hosts files) client1 client1.example.com client1 ( this was for the client1 host, the others were added accordingly: server1, server2, client2)

I can ssh to all the IP Addresses but I cannot ssh to the hostnames.

Any help is well appreciated.

Lowry

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: SSH ; can ssh IP, but cannot ssh to hostname

Post by TrevorH » 2014/10/15 01:49:15

Did you add them to DNS and/or /etc/hosts?
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

jxl1145
Posts: 36
Joined: 2014/09/14 01:14:32

Re: SSH ; can ssh IP, but cannot ssh to hostname

Post by jxl1145 » 2014/10/15 02:48:25

Hello,

Thank you for the reply.

OK, I messed up and here was the fix.

first, I do not know if this matters but I changed all my /etc/host files and left them default and then added on 3rd line:
IP Address fullhostname friendly name
xxx.xxx.xxx.xxx test.myserver.com test

Then, this was my real mistake:
when I created the hostname using hostnamectl I hade used the test.myserver.com as the hostnames instead of just hostname ( test)

I then rebooted all my kvm's just to be sure of the changes.

I tested both ways on all the kvm's and was able to ssh to all systems.

Thank You for your reply as I appreciate this forum and all the minds working together to learn Cent/RH.

Lowry

Post Reply