How to Install Vaultwarden on OpenBSD

Vaultwarden is an open source software for managing passwords securely. In this tutorial, we will go through the steps to install Vaultwarden on OpenBSD.

Prerequisites

Before you begin, make sure you have the following:

  • A server running OpenBSD
  • Root access to the server
  • An internet connection

Step 1: Install Dependencies

We need to install some dependencies to run Vaultwarden. Run the following command to install them:

sudo pkg_add rust cargo npm node gmake redis

Step 2: Download and Install Vaultwarden

  1. Clone the Vaultwarden repository from GitHub:

    git clone https://github.com/dani-garcia/vaultwarden.git
    
  2. Move into the repository folder:

    cd vaultwarden
    
  3. Build Vaultwarden from the source code:

    cargo build --release --features sqlite
    
  4. Install the dependencies needed for the web interface and build it:

    cd web-vault
    npm install
    npm run build
    

Step 3: Configure Vaultwarden

We need to create a configuration file for Vaultwarden. Copy the example configuration file and modify it for your use:

cd ..
cp .env.template .env
vi .env

Here are some of the settings you may want to change:

  • WEB_VAULT_PORT: The port on which the web interface is served from.
  • WEB_VAULT_URL: The URL of the web interface.
  • ADMIN_TOKEN: A secure token used to access the admin panel.

Step 4: Start and Automate Vaultwarden

To start Vaultwarden, run the following command:

./target/release/bitwarden_rs start

If you want Vaultwarden to start automatically when the server reboots, create a service unit file:

sudo vi /etc/rc.d/vaultwarden

Insert the following content inside the file:

#!/bin/sh
#
# Vaultwarden
#
# rc.conf variables:
#   bitwarden_rs_flags (str): flags to pass to bitwarden_rs binary.
#

daemon="/usr/local/bin/bitwarden_rs"
daemon_flags="start"

. /etc/rc.d/rc.subr

rc_stop() {
    ${daemon} stop
}

rc_cmd $1

Make the file executable:

sudo chmod +x /etc/rc.d/vaultwarden

Start the service:

sudo rcctl start vaultwarden

Conclusion

In this tutorial, we went through the steps to install and configure Vaultwarden on OpenBSD. Vaultwarden is now ready to securely manage your passwords.