How to Change an OpenBSD Server's Hostname Thoroughly
Mar 09, 2023 @ 7:54 pm
/
/
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 cthulhu.example.com.
First, use the hostname command:
# hostname cthulhu.example.com
Next modify /etc/myname to have the same information:
# cat /etc/myname
cthulhu.example.com
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.
Related Posts:
Let's Try BSD, Part 7 of 7: Conclusions About FreeBSD, OpenBSD, NetBSD, and DragonFlyBSD
Let's Try BSD, Part 6 of 7: Jump Into the Unknown With Me As I Install DragonFlyBSD!
Let's Try BSD, Part 5 of 7: Setting Up Nginx + WordPress on OpenBSD! Almost!
Let's Try BSD, Part 4 of 7: NetBSD, the BSD That Runs on Your Grandfather's Pocket Watch
Let's Try BSD, Part 3 of 7: FreeBSD, the Power to Serve
Let's Try BSD, Part 2 of 7: How I Setup for FreeBSD, OpenBSD, NetBSD, and DragonFlyBSD

Raindog308 is a longtime LowEndTalk community administrator, technical writer, and self-described techno polymath. With deep roots in the *nix world, he has a passion for systems both modern and vintage, ranging from Unix, Perl, Python, and Golang to shell scripting and mainframe-era operating systems like MVS. He’s equally comfortable with relational database systems, having spent years working with Oracle, PostgreSQL, and MySQL.
As an avid user of LowEndBox providers, Raindog runs an empire of LEBs, from tiny boxes for VPNs, to mid-sized instances for application hosting, and heavyweight servers for data storage and complex databases. He brings both technical rigor and real-world experience to every piece he writes.
Beyond the command line, Raindog is a lover of German Shepherds, high-quality knives, target shooting, theology, tabletop RPGs, and hiking in deep, quiet forests.
His goal with every article is to help users, from beginners to seasoned sysadmins, get more value, performance, and enjoyment out of their infrastructure.
You can find him daily in the forums at LowEndTalk under the handle @raindog308.
I’m confused about a few things and haven’t made this change yet. Can you share a more detailed cover letter?