What is Vaultwarden?
Vaultwarden is a lightweight, self-hosted password manager server that is fully compatible with official Bitwarden client apps and browser extensions. It acts as a secure digital vault to store, generate, and organize credentials.
To ensure zero-knowledge privacy, all vault data is encrypted locally on the user's device using AES-256-CBC with HMAC-SHA256 authentication before being sent to the server. Bitwarden clients communicate with the Vaultwarden backend over a secure connection using Transport Layer Security (TLS/HTTPS).
Installation
Create a Vaultwarden directory:
mkdir -p ~/docker/vaultwarden
Move to the Vaultwarden directory:
cd ~/docker/vaultwarden
Create the Docker compose file:
nano docker-compose.yml
Add the following:
services:
vaultwarden:
image: vaultwarden/server:latest
container_name: vaultwarden
restart: unless-stopped
security_opt:
- no-new-privileges:true
ports:
- 127.0.0.1:8080:80
volumes:
- ./vw-data:/data
environment:
SIGNUPS_ALLOWED: "true"
WEBSOCKET_ENABLED: "true"
Press CTRL+O to save the file, then press CTRL+X to close.
Start Vaultwarden:
docker compose up -d
If you are not already running a reverse proxy, install Caddy:
sudo apt install -y debian-keyring debian-archive-keyring apt-transport-https curl
Download and install the Caddy GPG key:
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
Add the Caddy software repository:
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | sudo tee /etc/apt/sources.list.d/caddy-stable.list
Update packages:
sudo apt update
Install Caddy:
sudo apt install caddy -y
Create a certificate directory:
sudo mkdir -p /etc/caddy/certs
Generate a certificate:
sudo openssl req -x509 -nodes -days 3650 \
-newkey rsa:4096 \
-keyout /etc/caddy/certs/vaultwarden.key \
-out /etc/caddy/certs/vaultwarden.crt
Configure Caddy:
sudo nano /etc/caddy/Caddyfile
Add these lines, replacing server-ip with your server IP address:
https://server-ip {
tls /etc/caddy/certs/vaultwarden.crt /etc/caddy/certs/vaultwarden.key
reverse_proxy 127.0.0.1:8080
}
Press CTRL+O to save the file, then press CTRL+X to close.
Set ownership of the certificate directory:
sudo chown -R caddy:caddy /etc/caddy/certs
Correct the permissions:
sudo chmod 750 /etc/caddy/certs
sudo chmod 640 /etc/caddy/certs/vaultwarden.crt
sudo chmod 640 /etc/caddy/certs/vaultwarden.key
Restart Caddy:
sudo systemctl restart caddy
Add a firewall rule to allow traffic on port 443 from your local subnet:
sudo ufw allow from 10.64.20.0/24 to any port 443 proto tcp
Confirm everything is working by accessing Vaultwarden in your browser, replacing server-ip with your server's IP address:
https://server-ip/
Click on Create account.
Follow the setup prompts.
Hardening
Now that your account has been created, disable new signups:
nano docker-compose.yml
Change SIGNUPS_ALLOWED to false:
SIGNUPS_ALLOWED: "false"
Press CTRL+O to save the file, then press CTRL+X to close.
Restart Vaultwarden:
docker compose up -d
Verify Vaultwarden is running:
docker ps
Create an update automation script:
sudo nano /usr/local/bin/vaultwarden-updates.sh
Add the below text, replacing user-name with the appropriate value:
#!/bin/bash
docker pull vaultwarden/server:latest
docker stop vaultwarden
docker rm vaultwarden
docker run -d \
--name vaultwarden \
--restart unless-stopped \
--security-opt no-new-privileges:true \
-p 127.0.0.1:8080:80 \
-v /home/werehoosier/docker/vaultwarden/vw-data:/data \
vaultwarden/server:latest
docker image prune -f
Press CTRL+O to save the file, then press CTRL+X to close.
Make the script executable:
sudo chmod +x /usr/local/bin/vaultwarden-updates.sh
Test the script:
sudo /usr/local/bin/vaultwarden-updates.sh
Schedule the script to run daily by adding a cron job:
sudo crontab -e
Add the following lines:
# Vaultwarden Updates
15 4 * * * /usr/local/bin/vaultwarden-updates.sh >> /var/log/vaultwarden-updates.log 2>&1
The update log can be checked by running the command:
sudo cat /var/log/vaultwarden-updates.log
Connecting to Bitwarden Extension
View the certificate on your server:
sudo cat /etc/caddy/certs/vaultwarden.crt
Copy the entire certificate.
Create a file on your local machine with the filename vaultwarden.crt.
Paste the certificate.
Save vaultwarden.crt.
If on Windows, click on the Start menu.
Open Manage Computer Certificates.
Expand Trusted Root Certification Authorities.
Right-click on Certificates.
Expand All Tasks.
Click on Import.
Follow the prompts to import vaultwarden.crt.
Open your web browser.
Install the Bitwarden browser extension if it is not already installed.
Click on the extension icon in your browser.
On the login page, click the Accessing dropdown near the bottom.
Select self-hosted.
Enter your server IP address as the Server URL.
Click on Save.
Log in using the credentials set up previously.