I’ve been a long time keepass (Actually keepassXC - a more maintained fork) and Syncthing for a password vault and syncing of the vault across machines. Bitwarden recently finished a security audit and that prompted me to look into setting up Bitwarden and possibly migrating to it (provided things worked)
-
Instead of the official Bitwarden server, I used the rust version of the server - Bitwarden_rs through it’s docker image.
-
Install docker if you haven’t done so -
sudo apt install docker.io
-
Download a caddy release from their github. We’ll use that for getting SSL certs from Lets encrypt and just SSL termination
-
Create a unprivileged user to run the docker image and the webserver (
caddy
)sudo useradd -r -s /bin/false bitwarden sudo usermod -a -G docker bitwarden sudo mkdir -p /home/bitwarden sudo chown bitwarden: /home/bitwarden sudo ufw allow https sudo ufw allow http sudo ufw allow 4443 sudo -Hu bitwarden -s bash cd ~ mkdir -p ~/vault mkdir -p ~/caddy cd caddy # wget and untar caddy release from their github page exit sudo setcap cap_net_bind_service=+ep /home/bitwarden/caddy/caddy sudo -Hu bitwarden docker run -d --name bitwarden -v /home/bitwarden/vault/:/data/ -p 4444:80 mprasil/bitwarden
-
Verify if you get the bitwarden page -
wget http://localhost:4444
-
TLS termination and proxying with caddy
sudo -Hu bitwarden cd ~/caddy vim Caddyfile # /home/bitwarden/caddy/Caddyfile https://vault.<yourdomain.com>:4443 { tls <email id here> proxy / localhost:4444 { except /.well-known transparent } log stdout errors stderr }
-
Make sure that you open necessary ports on your cloud provider - in this case 4443 and 80.
-
From your machine, opening
https://vault.yourdomain.com:4443
should work
Systemd
-
systemd unit file for running bitwarden
/etc/systemd/system/docker.bitwarden.service
[Unit] Description=docker.bitwarden Requires=docker.service After=docker.service [Service] Restart=always ExecStart=/usr/bin/docker run --name=%n --tty \ -v /home/bitwarden/vault:/data -p 4444:80 mprasil/bitwarden:alpine ExecStop=/usr/bin/docker stop -t 2 %n ; /usr/bin/docker rm -f %n [Install] WantedBy=multi-user.target
-
systemctl enable docker.bitwarden
-
systemctl start docker.bitwarden
-
-
Caddy - ships with systemd unit file - just make sure to point it to the actual Caddyfile.
Security
:: Disable signups . Create a dedicated admin account in bitwarden separate from your user account . after creating your account(s), run the docker image with the following env vars
+
-e SIGNUPS_ALLOWED=false \
-e INVITATIONS_ALLOWED=false \
-e SERVER_ADMIN_EMAIL=admin@example.com \
Backup
-
sqlite3 /home/bitwarden/db.sqlite3 ".backup '/home/bitwarden/backup.sqlite3'"
-
Cron + rclone the entire
/home/bitwarden/vault
Problems
-
Import from keepass XML does not import attachments - ticket 183
-
Login to sites that need more info doesn’t work. AFAICT, I cannot have a auto-type sequence as in keepass
References
-
Restart policy docs
-
systemd-docker Warning - last commit is 4 yrs ago!