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:   localhost localhost.localdomain localhost4 localhost4.localdomain4

::1         localhost localhost.localdomain localhost6 localhost6.localdomain6   server1.exampert.com    server1   server2.exampert.com    server2



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

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

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.

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

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.