Sat Dec 5 19:21 PM AKST 2026 || All Human, no AI || Powered by OpenBSDMain Menu: ( Home || About || Computer Repair || Install
Work in progress...
All configurations assume a standard OpenBSD install performed by OpenBSD.Amsterdam
OpenBSD.Amsteram VM's use the last whitespace separated field in the .ssh/authorized_keys file as the default root password. Run the following command to extract it:
# awk '{print $NF}' .ssh/authorized_keys
gGj8]jk94LH}jlsjieAn
Now copy it, execute 'su -' and paste it in, when prompted for the root 'Password:'
$ su - Password: #
You are now root and are able to change the password by executing the 'passwd root' command:
# passwd root Changing password for root. New password: Retype new password: passwd: password updated successfully #
Update your base system. This proceedure does not update third party packages but only the core base system.
# syspatch
This procedure is for major release" upgrades e.g. from 7.9 to 8.0. Before you upgrade ensure the /usr partition has at least 1.1G available.
# df -h /usr # sysupgrade
In this case we will change it to 37777 by finding the '#Port 22' line in /etc/ssh/sshd.config file and changing it to '37777':
# vi /etc/ssh/sshd.config #Port 22 Port 37777
In this case we will set the system name to 'alaskalinux'
# hostname alaskalinux
In this case we will switch our time zone to Anchorage America:
# ln -sf /usr/share/zoneinfo/America/Anchorage /etc/localtime
OpenBSD systems use ksh by default and not Bash. When you login into your system, ksh reads '.profile' to configure itself. This is called your login shell. However it is very common to initiate sub ksh shells to handle different processes, scripts, views, etc. Almost always we want to control the environment these ksh sub-shells receive so we add this line to the bottom of '.profile':
# vi .profile PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin export PATH HOME TERM export ENV=$HOME/.kshrc
We want all of our sub-shells to have a consistent view as well so by adding the 'export ENV=$HOME/.kshrc' line we can now put any sub-shell configurations in '.kshrc' For example, to enable Command Line History, Set the command line history file size, ignore duplicate commands and emacs style keybindings and change the PS1 command prompt color to blue:
# vi .kshrc export HISTFILE="$HOME/.ksh_history" export HISTSIZE=10000 export HISTCONTROL=ignoredups:ignorespace set -o emacs export PS1='\[\033[0;94m\]\u@\h:\w\$\[\033[0m\] '
I do exactly the same updates to '.profile' and '.kshrc' for root as well but I change the PS1 prompt color from blue to hot pink:
# cat .profile PATH=$HOME/bin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/bin:/usr/local/sbin export PATH HOME TERM export ENV=$HOME/.kshrc # cat .kshrc export HISTFILE="$HOME/.ksh_history" export HISTSIZE=10000 export HISTCONTROL=ignoredups:ignorespace set -o emacs export PS1='\[\033[38;5;199m\]\u@\h:\w\$\[\033[0m\] '
My configuration is basic, however the OpenBSD Handbook is an excellent resource for all things OpenBSD including the configuration of httpd. Httpd's default config file /etc/httpd.conf after I changed 'server "default"' to 'server "alaskallinux.com':
# vi /etc/httpd.conf
types { include "/usr/share/misc/mime.types" }
server "alaskalinux.com" {
listen on * port 80
root "/htdocs"
}
Before we start httpd we need to create an index.html file in /var/www/htdocs/
# echo "Thank you OpenBSD! Living the Dream, from Alaska!" > /var/www/htdocs/index.html
Restart httpd:
# rcctl enable httpd # rcctl start httpd
Now, open your browser, input your OpenBSD servers IP address in the address bar, enter the IP address of your OpenBSD server and hit enter. You should get the index.html page you made.
Create ACME challenge directory aka the directory that will contain files validating we own the website.
# install -d -o root -g www -m 0755 /var/www/acme
Configure httpd to use /var/www/acme
# vi /etc/httpd.conf
server "alaskalinux.com" {
alias "www.alaskalinux.com"
listen on * port 80
root "/htdocs/"
# ACME http-01 challenge
location "/.well-known/acme-challenge/*" {
root "/acme"
request strip 2
directory no auto index
}
}
Reload httpd
# rcctl reload httpd
Create /etc/acme-client.conf:
# vi /etc/acme-client.conf
authority letsencrypt {
api url "https://acme-v02.api.letsencrypt.org/directory"
account key "/etc/acme/letsencrypt-privkey.pem"
}
domain "alaskalinux.com" {
alternative names { "www.alaskalinux.com" }
domain key "/etc/ssl/private/alaskalinux.com.key"
domain full chain certificate "/etc/ssl/alaskalinux.com.fullchain.pem"
sign with letsencrypt
challengedir "/var/www/acme"
}
Request TLS certificate
acme-client -v alaskalinux.com && doas httpd -n && rcctl reload httpd
Enable HTTPS and redirect HTTP to HTTPS:
location * {
block return 301 "https://$HTTP_HOST$REQUEST_URI"
}
} #<-- this closes your original server {} stanza
# HTTPS: primary site
server "alaskalinux.com" {
listen on * tls port 443
hsts
tls {
certificate "/etc/ssl/alaskalinux.com.fullchain.pem"
key "/etc/ssl/private/alaskalinux.com.key"
}
root "/htdocs/"
directory index "Home.html"
}
For reference, here is my final /etc/httpd.conf
To install the 'goaccess' page use the 'pkg_add' command:
# pkg_add goaccess
Now we configure the 'time-format', 'date-format' and 'log-format' directives in /etc/goaccess/goaccess.conf. Locate these directives in goaccess.conf By default OpenBSD uses the 'common log' format so add the three lines below the '#httpd(8) common log format' line like so:
# vi /etc/httpd.conf # httpd(8) common log format #date-format %d/%b/%Y #time-format %T %z #log-format %v %h %^ %^ [%d:%t] "%r" %s %b date-format %d/%b/%Y time-format %H:%M:%S %z log-format %v %h %^ %e [%d:%t] "%r" %s %b
Now locate the 'exclude-ip' directive in goaccess.conf. I exclude my own IP address from affecting the log analysis. For larger organizations, I would NOT exclude "monitoring system" IP's until there is a known good baseline for their traffic signatures.
# vi /etc/goaccess/goaccess.conf #exclude-ip 127.0.0.1 #exclude-ip 192.168.0.1-192.168.0.100 #exclude-ip ::1 #exclude-ip 0:0:0:0:0:ffff:808:804-0:0:0:0:0:ffff:808:808 exclude-ip 8.8.8.8 # Your IP here
And finally we can use goaccess to generate our log report. The first example uses the updated configurations from /etc/goaccess/goaccess.conf and the second example runs an live report using command line options to overide those in 'goaccess.conf'
# cd /var/www/logs/ # goaccess /var/www/logs/access.log -o report.html # goaccess /var/www/logs/access.log --log-format='%v %h %^[%d:%t %^] "%r" %s %b "%R" "%u"' --date-format=%d/%b/%Y --time-format=%T
OpenBSD makes extensive use of the built-in mail subsystem. You as an administrator will need to learn how to "read" and "delete" system mail. Please note this is not internet routable email, rather this mail is sent by the system itself to you the administrator. Use the 'mail' command to check system or cron mail sent to you.
To read each mail simply hit 'enter'
To delete all mail type 'd *' like so:
# d *
Cron, the god of time or in our case the tool we use to automate system tasks. Example uses of cron include backing up ones website, monitoring resources, etc. In this example I create a cron job to back up my website. It is a simple ksh script, located in /root/bin/' named 'backup_website.sh'. The script is executed every 10 miutes by cron, copying my website directory: '/var/www/htdocs/' to '/root/bk/' the back up directory while discarding the scripts output so it isn't mailed to me by cron. Finally, we will add a cronjob for to automatically renew our httpd Let's Encrypt certificates
# crontab -e */10 * * * * /bin/ksh /root/bin/backup_website.sh >/dev/null 2>&1 ~ 3 * * * acme-client alaskalinux.com && rcctl reload httpd
Here is the 'backup_website.sh' script:
# cat bin/backup_website.sh
#!/bin/ksh
site="/var/www/htdocs"
backupdir="/root/bk/"
cd ${site}
cp -r * ${backupdir}
Update third party packages installed after the original system build. This doesn't upgrade the base system, rather packages the admin has installed after the system was built like Goaccess, Git, Tmux, Firefox, etc.
# pkg_add -u
As an admin one of the single best practices is to inventory your system the moment you have hardened it. You want to establish what your system "should" look like. For example, determine the default setuid/setgid binaries installed, partitions, processes running on your system, which network ports they use and associated configuration files. This enables you to more easily detect systemmic anomalies such as rouge processes, connections, unexpected binaries or configuration file changes, etc. OpenBSD by default includes a "security report script" /etc/daily run daily by cron. In addition to the security checks performed by this script below are some commands to help baseline your OpenBSD system:
Prints system identification details—like the OS name, hostname, release, version, and architecture—to standard output
# uname -a
Show enabled daemons:
# rcctl ls on
Show all running processes
# ps aux
Display listening IPv4 sockets:
# netstat -na -f inet
Display listening IPv6 sockets:
# netstat -na -f inet6
List all processes using UDP
# fstat | grep udp
List all processes using TCP
# fstat | grep tcp
List third party installed packages
# pkg_info -mz
List all setuid binaries, included by /etc/daily security script
# find / -perm -4000 -type f 2>/dev/null
List all setgid binaries, included by /etc/daily security script
# find / -perm -2000 -type f 2>/dev/nullMuch more to come...