I have been using Firefox’s inbuilt password manager for quite some time and was quite happy with how it worked. However I recently received alerts from various accounts regarding suspicious login attempts from various places I have never been, so I started looking for something more secure and feature-rich and learned about bitwarden. I got my hands on the oracle cloud free-tier and was able to spin up a compute instance and since it fit the bill, I decided to use it as the host for my password manager.
Digging around a bit led me to vaultwarden, an Unofficial Bitwarden compatible server written in Rust for lightweight installations. Since my server has a mere gigabyte of RAM this seemed perfect for me. Here are the steps that I took to install it properly including HTTPS support and disallowing account creation.
The Linux Server I am using here is an Ubuntu Server 20.04. Feel free to adjust according to your Distribution. You also require a domain name to properly setup SSL.
Installing Things
We need to firstly install some softwares that will help us setup the vaultwarden service.
- First install docker
- Replace user in the next command to your usename to give docker user permissions
- Check if docker is properly configured using
If you see a message like this, you have successfully installed and configured docker.
- Now pull vaultwarden’s docker image
- Now we will install certbot to help us generate a SSL certificate using LetsEncrypt
- We will also install nginx to help us create a reverse proxy to talk to vaultwarden over HTTPS
Setting up certbot
- Get the DNS auth file and set it up
Use your Domain name provider to change your DNS settings and point your domain/subdomain to the IP Address of the Server.
- Execute the auth file to create a request and replace vault.example.com with your domain
It will promt you to add a CNAME to your DNS. After Adding the Record Press Enter. You will see something like this :
If it fails due just wait a few minutes and run the command again. It is likely due to dns replication timings.
- Test the automatic certificate generation to check if cerbot is properly configured
You should see something Like this
You have successfully configured your SSL Certificate.
Setting up vaultwarden and Nginx
- Start the vaultwarden container on any port, I use port 8080
- Setup Nginx by creating a conf file
Change the ports and the domain/subdomain according to your configuration :
- Restart nginx for the config to take effect
Now goto your website https://vault.example.com/ and if you can see the bitwarden login page Congratulations! you have successfully managed to install vaultwarden.
If you cannot see the login page, make sure port 443 is open on your server. Also make sure ufw or iptable allows connections on port 443. I wasn’t able to get my page to work properly because iptables wasn’t configured to allow connections on 443: I solved it using:
Create your account on the same page.
Disabling User Sign Up
Make sure to create an account for yourself before proceeding as you wont be able to create accounts after this.
- Stop the vaultwarden container and remove it
- Run the conainer once more with same data directory but with SIGNUPS_ALLOWED environment variable as false
Now account creation is disabled and noone else can create an account.
Congratulations you now have a working, self-hosted password manager on your own server! you can use the standard bitwarden app for Android/IOS as well as the bitwarden extensions to use your password manager.
Sources
https://www.llewellynhughes.co.uk/post/installing-vaultwarden/
https://github.com/joohoi/acme-dns-certbot-joohoi
https://www.linode.com/docs/guides/how-to-self-host-the-vaultwarden-password-manager/
https://certbot.eff.org/lets-encrypt/ubuntufocal-nginx