How to Change an OpenBSD Server’s Hostname Thoroughly

Changing host names on Unix is surprisingly complicated and implementation-specific.  Even though there is a “hostname” command in most (all?) Unices, it generally doesn’t change everything.

After recently renaming an OpenBSD system, I thought I’d make a quick howto.  In this example, I’ll change a server the new name

First, use the hostname command:

# hostname

Next modify /etc/myname to have the same information:

# cat /etc/myname

Update /etc/hosts, replacing the old hostname with the new.

Finally replace the host keys:

# cd /etc/ssh
# rm -f *_key *.pub
# ssh-keygen -A

And that’s it for the base system.  Consider other software you might have installed such as mail, etc.

Please follow and like us: