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:
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
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:
Mission change host accomplished, Enjoy 🙂