LowEndBox - Cheap VPS, Hosting and Dedicated Server Deals

How to Change an OpenBSD Server's Hostname Thoroughly

OpenBSD Wireframe PuffyChanging 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.

raindog308

1 Comment

  1. I’m confused about a few things and haven’t made this change yet. Can you share a more detailed cover letter?

    March 9, 2023 @ 11:22 pm | Reply

Leave a Reply

Some notes on commenting on LowEndBox:

  • Do not use LowEndBox for support issues. Go to your hosting provider and issue a ticket there. Coming here saying "my VPS is down, what do I do?!" will only have your comments removed.
  • Akismet is used for spam detection. Some comments may be held temporarily for manual approval.
  • Use <pre>...</pre> to quote the output from your terminal/console, or consider using a pastebin service.

Your email address will not be published. Required fields are marked *