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

  • 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 192.168.245.2 nameserver 8.8.8.8 nameserver 8.26.56.26 ~ – sf31 Jul 20 '18 at 19:19
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.

  • 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 acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.