Setting up Self-Hosted Bitwarden on the Raspberry Pi

Bitwarden is an open-source password manager that helps you store and manage your credentials securely. Hosting your own Bitwarden server on a Raspberry Pi gives you full control over your data and enhances security. In this guide, we will walk you through the process of setting up Bitwarden on a Raspberry Pi using Docker.


What You Will Need

  1. Raspberry Pi (any model with sufficient resources, Pi 3 or Pi 4 recommended)
  2. Raspberry Pi OS installed and running
  3. Docker and Docker Compose installed
  4. Domain name (optional but recommended for secure HTTPS access)
  5. Internet connection for downloading required files
  6. Bitwarden docker-compose.yml file

Step 1: Update Your Raspberry Pi

Before starting, it's important to update your Raspberry Pi to the latest version:

sudo apt update
sudo apt upgrade -y

Reboot your Raspberry Pi to ensure everything is up to date:

sudo reboot

Step 2: Install Docker

Docker is a tool that allows you to run applications in containers. Follow these steps to install Docker on your Raspberry Pi:

  1. Download and install Docker using the official script:
curl -sSL https://get.docker.com | sh
  1. Add your user to the Docker group to avoid needing sudo for Docker commands:
sudo usermod -aG docker $USER
  1. Restart the Raspberry Pi to apply the group changes:
sudo reboot
  1. Verify the installation:
docker --version

Step 3: Install Docker Compose

Docker Compose is a tool for defining and running multi-container Docker applications. Bitwarden requires multiple containers to run, and Docker Compose simplifies this process.

  1. Download and install Docker Compose:
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
  1. Make the Docker Compose binary executable:
sudo chmod +x /usr/local/bin/docker-compose
  1. Verify the installation:
docker-compose --version

Step 4: Download Bitwarden Docker Compose Files

Bitwarden provides an official Docker Compose setup to deploy its server. We will download and configure these files:

  1. Create a directory to store the Bitwarden files:
mkdir ~/bitwarden
cd ~/bitwarden
  1. Clone the Bitwarden repository from GitHub:
git clone https://github.com/bitwarden/server.git .

Step 5: Configure Bitwarden

Before running Bitwarden, you need to configure it to match your environment.

  1. Environment Variables: In the bwdata folder (created by Docker Compose), you will need to configure several environment variables like the database and encryption keys. You can refer to the config.yml file to make the necessary changes.
  2. Set up a Domain Name: You can optionally use a domain name for accessing Bitwarden. This is recommended for secure HTTPS access. If you don’t have a domain, you can skip this step and use your Pi’s local IP address.

If you’re using a domain, make sure to update your DNS records to point to the Raspberry Pi’s IP address.


Step 6: Set Up SSL (HTTPS)

To secure the Bitwarden instance, it's recommended to use HTTPS for encryption. You can either use a self-signed certificate or a free SSL certificate from Let’s Encrypt.

Using Let’s Encrypt with Nginx (Optional)

  1. Install Nginx and Certbot for SSL certificate management:
sudo apt install -y nginx certbot python3-certbot-nginx
  1. Obtain the SSL certificate using Certbot:
sudo certbot --nginx -d yourdomain.com
  1. Follow the on-screen prompts to complete the process.

Step 7: Start Bitwarden with Docker Compose

Now, you can start the Bitwarden containers using Docker Compose.

  1. Navigate to the bitwarden directory:
cd ~/bitwarden
  1. Run the following command to start Bitwarden:
docker-compose up -d

This command will download the required Docker images and run Bitwarden in the background. You can check the logs to ensure that everything is running smoothly:

docker-compose logs -f

Step 8: Access Bitwarden

Once the containers are up and running, you can access the Bitwarden server in your web browser:

  • If you set up a domain, navigate to https://yourdomain.com
  • If you’re using the Raspberry Pi’s IP address, navigate to http://<Pi_IP>:8080

Step 9: Set Up the Admin Panel (Optional)

If you want to access the Bitwarden admin panel to manage users and settings, you can create an admin account by following these steps:

  1. In the Bitwarden directory, create an .env file with your admin settings:
touch .env
  1. Add the following content to the .env file:
# Admin username and password
ADMIN_EMAIL=admin@yourdomain.com
ADMIN_PASSWORD=your_secure_password
  1. Rebuild the Docker container to apply the changes:
docker-compose down
docker-compose up -d

You can now access the admin panel via the web interface.


Step 10: Test and Use Bitwarden

Once everything is up and running, you can test the Bitwarden login by navigating to the web interface and logging in with the credentials you created. You can now use Bitwarden for storing and managing passwords securely.


Troubleshooting

  • Bitwarden not starting: Check the Docker logs to ensure there are no issues with the container setup:

    docker-compose logs -f
    
  • SSL errors: Ensure your SSL certificate is correctly installed and the domain is pointing to your Raspberry Pi’s IP.

  • Database issues: Ensure the database and encryption keys are correctly configured in the config.yml file.


Conclusion

By following these steps, you have successfully set up a self-hosted Bitwarden password manager on your Raspberry Pi. This setup provides a secure and private way to manage your passwords and credentials, and with Docker, it’s easy to maintain and update. Enjoy the benefits of a self-hosted password manager!

Leave a comment

Notice an Issue? Have a Suggestion?
If you encounter a problem or have an idea for a new feature, let us know! Report a problem or request a feature here.