How to Install and Set Up OpenBSD 8.0 on a VPS
Install OpenBSD 8.0 on a VPS from the official install image and complete the first-time setup recommended in afterboot(8).
This guide installs OpenBSD 8.0 (amd64), the current release, on a KVM-based VPS from the official install image and then walks through the first-time setup the project recommends in afterboot(8): patches, a regular user with doas, SSH access and packages. It applies to any provider that lets you boot your own ISO image and gives you a web or VNC console.
Requirements
- A 64-bit x86 VPS on which you can attach a custom ISO and open a graphical console. OpenBSD boots with both BIOS/MBR and UEFI/GPT.
- Disk space: the project recommends 8 GB or more for most users. Smaller disks work but leave little room and make upgrades harder.
- The network details of the server if your provider does not hand them out by DHCP: IPv4 address, netmask, default gateway and DNS servers. You find them in your hosting control panel.
Step 1: Get and verify the install image
The amd64 directory of every OpenBSD mirror contains several images. For a VPS the useful ones are:
| File | Use |
|---|---|
install80.iso | CD image that includes the file sets; installs without downloading anything |
cd80.iso | Small CD image without the file sets; they are fetched from a mirror during installation |
install80.img | Disk image with the file sets, for providers that boot a raw disk or USB image instead of an ISO |
Most control panels accept a URL and fetch the image themselves. Give it the address of install80.iso on the project's CDN:
https://cdn.openbsd.org/pub/OpenBSD/8.0/amd64/install80.iso
If you download the image to your own computer first, check it against the SHA256 file from the same directory. On Linux:
wget https://cdn.openbsd.org/pub/OpenBSD/8.0/amd64/install80.iso
wget https://cdn.openbsd.org/pub/OpenBSD/8.0/amd64/SHA256
sha256sum -c --ignore-missing SHA256
This detects a damaged download. On an existing OpenBSD system you can go further and verify the signed checksum file with signify -Cp /etc/signify/openbsd-80-base.pub -x SHA256.sig install80.iso. If the control panel shows a checksum after it has fetched the image, compare it with the line for that file in SHA256.
Step 2: Boot the installer
Attach the ISO to the server, start it and open your provider's web console. After the kernel messages the installer asks:
(I)nstall, (U)pgrade, (A)utoinstall or (S)hell?
Type i and press Enter. From here on every question shows its default answer in square brackets, and pressing Enter accepts it. For a simple server the defaults are right for most questions.
Step 3: Answer the installer's questions
The questions come in this order:
- Keyboard layout. The default is US. Enter your layout code if it differs, because you are about to type passwords.
- System hostname. The short name, for example
bsd1. - Network interface. On a KVM guest with a virtio network card the interface is usually
vio0. For IPv4 enterdhcpif your provider supports it, otherwise type the address, then the netmask. For IPv6 enterautoconfor a static address, or skip it. With a static address the installer then asks for the default route and the DNS servers. - Root password. Entered twice. Use a strong one; you will rarely need it once
doasis set up. - Start sshd by default? Answer yes.
- Run the X Window System? Answer no on a server.
- Set up a user? Enter a login name such as
deploy, then a full name and a password. Create this account now; it is the one you will log in with. - Allow root ssh login? Asked when you created a user and enabled
sshd. Answer no. - Time zone. For example
UTCorEurope/Berlin. - Root disk. Normally
sd0. At the next prompt enterwto use the whole disk with an MBR, orgfor GPT on a UEFI machine. - Partition layout. The installer proposes an automatic layout based on the disk size, with separate file systems such as
/,/var,/usr,/usr/localand/home. Accept the auto layout unless you have a specific reason to edit it. - Location of sets. With
install80.isochoosecd0and accept the path8.0/amd64. Withcd80.isochoosehttpand accept the proposed mirror. - Set selection. All sets are selected by default and the project advises new users to install them all. On a server without a graphical desktop you can deselect the X sets by entering
-x*, thendone.
When you install from install80.iso, the installer warns that it cannot verify the sets because the image carries no signature file, and asks whether to continue. If you verified the image in step 1, answer yes.
After the sets are extracted the installer writes the configuration and tells you the installation is complete. Detach the ISO in your control panel so the server boots from its disk, then reboot:
reboot
Step 4: First login and patches
Log in on the console as root. The first boot takes a little longer because the system generates SSH host keys and relinks the kernel. Root has a welcome message from the installer; read it with mail.
Install the binary patches that have been published for the release since it came out, then reboot if a kernel patch was among them:
syspatch
syspatch is available on amd64, arm64 and i386 and only for supported releases. Run it again from time to time and after every errata announcement.
Step 5: Set up doas for your user
OpenBSD uses doas instead of sudo. It has no rules until you create /etc/doas.conf. Make sure your user is in the wheel group and allow that group to run commands as root, with the password remembered for a short time:
usermod -G wheel deploy
echo "permit persist :wheel" > /etc/doas.conf
Log out, log in as deploy and test it:
doas -u root id
From now on work as the regular user and prefix administrative commands with doas. Commands run through doas are logged to /var/log/secure. A commented example file is in /etc/examples/doas.conf.
Step 6: Check the network, clock and SSH
Work through the checks from afterboot(8):
hostname
ifconfig -a
route -n show
host openbsd.org
ntpctl -s status
df -h
The files behind these settings are short and plain:
| File | Content |
|---|---|
/etc/myname | The host name |
/etc/hostname.vio0 | Configuration of the interface vio0, for example inet 203.0.113.10 255.255.255.0 or inet autoconf |
/etc/mygate | The default gateway |
/etc/resolv.conf | DNS servers; maintained at runtime by resolvd |
After editing the network files, apply them without a reboot:
doas sh /etc/netstart
Connect over SSH from your own computer as deploy. Copy your public key to ~/.ssh/authorized_keys on the server, then confirm that root logins over the network are refused: /etc/ssh/sshd_config should contain PermitRootLogin no. After changing that file, restart the daemon:
doas rcctl restart sshd
Step 7: Install packages and enable services
Packages come from the mirror named in /etc/installurl, which the installer sets up. Search for a package, install it, and later update everything that is installed:
pkg_info -aQ rsync
doas pkg_add rsync
doas pkg_add -u
Services are managed with rcctl, which writes to /etc/rc.conf.local. Do not edit /etc/rc or /etc/rc.conf themselves. For example, to enable and start the web server from the base system once you have written its configuration:
doas rcctl enable httpd
doas rcctl start httpd
Sample configuration files for the base daemons are in /etc/examples.
Step 8: Mail for root and the nightly reports
OpenBSD mails the output of its daily, weekly and monthly maintenance scripts, including a security report, to root. Send that mail to an address you read by editing /etc/mail/aliases, setting the root: line to your user or an external address, and rebuilding the alias database:
doas newaliases
After the first night, read the report with the subject ending in "daily insecurity output" and fix anything it lists. Local additions to the periodic jobs go in /etc/daily.local, /etc/weekly.local and /etc/monthly.local.
Keeping the system current
Between releases, syspatch for the base system and pkg_add -u for packages are all you need. When a new release comes out, sysupgrade downloads and verifies its file sets, reboots into the upgrade kernel and performs an unattended upgrade to the next release:
doas sysupgrade
Read the upgrade guide for that release on the OpenBSD site first; it lists configuration changes you have to make by hand. Upgrade one release at a time, and run doas pkg_add -u after the system comes back up. The complete post-install checklist is in the manual: man afterboot, also available at man.openbsd.org/afterboot. The installation chapter of the OpenBSD FAQ covers the installer in more depth.
Frequently asked questions
Which image should I pick, install80.iso or cd80.iso?
install80.iso contains the file sets, so the installation works even before the network is configured correctly. cd80.iso is much smaller and quicker to upload but needs a working network connection during the installation to fetch the sets from a mirror.
I skipped a file set. How do I add it later?
Boot the bsd.rd ramdisk kernel from the installed system, either by typing boot bsd.rd at the boot prompt or by attaching the ISO again, choose Upgrade and select the missing sets.
Can the installation be automated?
Yes. The installer's Autoinstall mode reads the answers from a response file fetched over the network, and files such as install.site and a site80.tgz set let you run your own commands and add your own files during installation. This is described in autoinstall(8) and the FAQ.
How long is a release supported?
OpenBSD publishes a new release about every six months and provides patches for the two most recent ones. Plan to run sysupgrade at least once a year, and preferably after every release.