I had to configure a newly purchased dedicated server from UK2. New servers cames shipped with some random assigned node hostname like server42803. This is pretty annoying, and has to be changed especially if your company has a naming server policy in some format like; company-s1#, company-s2#, company-sN#.
Changing hostname via hosts definition file /etc/hosts to assign the IP address of the host to the hostname is not enough for changing the hostname shown in shell via SSH user login.
To display full hostname on Debian and Ubuntu, had to type:
server42803:~# hostname
server42803.uk2net.com
To change permanently server host to lets say company-s5;
server42803:~# cat /etc/hostname |
sed -e 's#server42803.uk2net.com#company-s5#' > /etc/hostname
To change for current logged in SSH session:
server42803:~# hostname company-s5
company-s5:~#
Finally because already old hostname is red by sshd, you have to also restart sshd for new hostname to be visible on user ssh:
company-s5:~# /etc/init.d/ssh restart
...
As well as run script:
company-s5:~# /etc/init.d/hostname.sh
Mission change host accomplished, Enjoy 🙂
More helpful Articles

Tags: hostname, hosts, ip address, Linux, node, server host, server policy, servers, session 3a, Shell, sshd, type 3a, ubuntu linux