Vaultwarden is a free and open-source password management software that allows users to securely store passwords and other sensitive information. In this tutorial, we will guide you through the process of installing Vaultwarden on NetBSD.
Before you begin, ensure you have the following:
Open the terminal on your NetBSD server and change to the /opt
directory.
cd /opt
Clone the Vaultwarden repository from GitHub.
git clone https://github.com/dani-garcia/vaultwarden.git
Change into the cloned directory.
cd vaultwarden
Build the Vaultwarden binary using Cargo.
cargo build --release
Note: This process may take a few minutes.
Once the build is complete, verify that the binary is built successfully by navigating to the target/release
directory.
cd target/release
ls
Next, create a new configuration file for Vaultwarden.
cd /opt/vaultwarden
curl -o ./config.env https://raw.githubusercontent.com/dani-garcia/vaultwarden/main/.env.template
Edit the configuration file to suit your needs.
nano ./config.env
Note: When you are done, save and exit the editor.
Now, create a system service file for Vaultwarden to run as a daemon using the following command.
cd /etc/rc.d/
touch vaultwarden
nano vaultwarden
Copy and paste the following script into the file you just created.
#!/bin/sh
# PROVIDE: vaultwarden
# REQUIRE: NETWORK
# KEYWORD: shutdown
. /etc/rc.subr
name="vaultwarden"
daemon="/opt/vaultwarden/target/release/vaultwarden"
process="/opt/vaultwarden/target/release/vaultwarden"
command="/usr/sbin/daemon -u _vaultwarden -f -p /var/run/$name.pid $daemon $DAEMON_OPTS"
extra_commands="status"
pidfile="/var/run/$name.pid"
rcvar=$(set_rcvar)
start_precmd=start_precmd
start_precmd()
{
if [ -n "${VAULTWARDEN_USER}" ]; then
_vaultwarden_user=${VAULTWARDEN_USER}
else
_vaultwarden_user="_vaultwarden"
fi
if ! /usr/bin/id $_vaultwarden_user >/dev/null 2>&1; then
/usr/sbin/useradd -U -d /var/empty -s /sbin/nologin $_vaultwarden_user >/dev/null 2>&1
fi
/bin/chown -R $_vaultwarden_user $_vaultwarden_datadir
}
command_args="$command_args $process"
status()
{
pid=$(cat $pidfile 2>/dev/null) || :
if [ -n "$pid" -a -d /proc/$pid ]; then
echo "Vaultwarden is running (pid $pid)."
exit 0
else
echo "Vaultwarden is not running."
exit 1
fi
}
run_rc_command "$1"
Note: Save and exit the editor when you are done.
Make the file executable by running the following command.
chmod +x /etc/rc.d/vaultwarden
rcctl -a enable vaultwarden
rcctl -a start vaultwarden
Congratulations! You have now successfully installed Vaultwarden on NetBSD. You can now access Vaultwarden on your preferred web browser by going to http://your_server_IP:80
.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!