1

Please notice that I don't have any problem with hostname and I can change the hostname by configuring /etc/hostname , and it is easily shown on the terminal.

My problem: I just setup two servers on CentOS 7, they are not real servers of course, but when I connect to them using ssh, the hostname doesn't replace by server name and it still shows me root@localhost on the terminal instead of root@server1 OR root@server2 .

The hostname is localhost.localdomain.

/etc/hosts:

27.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.122.1   server1.exampert.com    server1

192.168.122.2   server2.exampert.com    server2

/etc/hostname:

localhost.localdomain

This question has not been answered. my problem is with hostname which comes after root@ on the terminal when I use ssh command! if I change /etc/hostname or other commands, hostname changes on the terminal as well, but when I use ssh server1 the hostname is still as it was before using the ssh command! I expect it to be root@server1 instead of root@localhost~

What could be the problem?

ScreenShot link

2
  • have you edited something in your profile? Also whats in /etc/resolv.conf?
    – alpha
    Commented Jul 19, 2018 at 14:01
  • what do you mean by profile? this is the resolv.conf file: search localdomain exampert.com nameserver 192.168.245.2 nameserver 8.8.8.8 nameserver 8.26.56.26 ~
    – sf31
    Commented Jul 20, 2018 at 19:19

1 Answer 1

0

Have you tried setting hostname via hotnamectl?

hostnamectl set-hostname your-new-hostname

in order for the change to take effect you have to reboot the machine.

1
  • As I said I can change the hostname w/o any problem, it would be appeared in the terminal.
    – sf31
    Commented Jul 20, 2018 at 19:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .