Alaska Linux
 Fri Dec  4 13:29 PM AKST 2026 ||  All Human, no AI  ||  Powered by OpenBSD
Main Menu: ( Home || About || Computer Repair || Install Linux OpenBSD || World News || Well Being )

Deploying an OpenBSD Server using a OpenBSD.Amsterdam VM


Work in progress...
All configurations assume a standard OpenBSD install performed by OpenBSD.Amsterdam


Reset root password

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
#

Change sshd's default listening port to something else

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

Set System Name

In this case we will set the system name to 'alaskalinux'

#hostname alaskalinux

Set Timezone

In this case we will switch our time zone to Anchorage America:

#ln -sf /usr/share/zoneinfo/America/Anchorage /etc/localtime

Configure KSH

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\] '

Configure httpd, OpenBSD's built-in webserver

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, it looks like this:

types { include "/usr/share/misc/mime.types" }

server "default" {
    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.


Install and Configure Goaccess web log analyzer

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:

# 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

Check System Mail

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.

#mail

To read each mail simply hit 'enter'

To delete all mail type 'd *' like so:

#d *

Create Cronjobs

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.

*/10 * * * * /bin/ksh /root/bin/backup_website.sh >/dev/null 2>&1

Here is the 'backup_website.sh' script:

#!/bin/ksh

site="/var/www/htdocs"
backupdir="/root/bk/"

cd ${site}
cp -r * ${backupdir}

Baseline your system

As an admin one of the single best practices is to inventory your system the moment you have hardened it. For example, determine the default binaries installed, partitions, processes running on your system, which network ports they use and associated configuration files; over all define what your system should "look like". This enables you to more easily detect systemmic anomalies such as rouge processes, connections, unexpected binaries or configuration file changes, etc. Below are some commands tobaseline your OpenBSD system:

# uname -a
Much more to come...