[Guide] Automating Bitwarden Updates on Linux (.deb Package)

A Simple Auto-Update Script for Bitwarden Desktop

Hey everyone! :wave:

If you’re using Bitwarden Desktop on Linux (installed via .deb package), you might have noticed that it doesn’t update automatically. After some testing and optimizations, I’ve created a simple script that:

:heavy_check_mark: Checks if Bitwarden is up-to-date before downloading anything.
:heavy_check_mark: Fetches the latest version directly from Bitwarden’s official website (not GitHub).
:heavy_check_mark: Updates only when needed—saving bandwidth and time.
:heavy_check_mark: Runs instantly with minimal delay.

:small_blue_diamond: How It Works

The script extracts the latest version number from Bitwarden’s official download URL.
If the installed version is already the latest, the script exits immediately.
Otherwise, it downloads and installs the update automatically.

The Script

Copy and paste the following script into a file, e.g., update-bitwarden.sh, save it in the user’s home directory, and make it executable.

#!/bin/bash

# Define variables
DOWNLOAD_PAGE="https://bitwarden.com/download/?app=desktop&platform=linux&variant=deb"
DOWNLOAD_DIR="$HOME/Downloads"
BITWARDEN_DEB="$DOWNLOAD_DIR/bitwarden-latest.deb"

echo "🔍 Checking the installed Bitwarden version..."

# Get the installed Bitwarden version from dpkg
INSTALLED_VERSION=$(dpkg-query --showformat='${Version}' --show bitwarden 2>/dev/null)

# If Bitwarden is not installed, assume it needs to be installed
if [[ -z "$INSTALLED_VERSION" ]]; then
    echo "⚠️ Bitwarden is not installed. Proceeding with installation..."
    NEEDS_UPDATE=1
else
    echo "✅ Installed Bitwarden version: $INSTALLED_VERSION"
fi

# Fetch the final redirected URL from Bitwarden's official download page
echo "🔍 Fetching the latest Bitwarden version from the official website..."
REDIRECTED_URL=$(curl -sI "$DOWNLOAD_PAGE" | grep -i "location" | awk '{print $2}' | tr -d '\r')

# Extract the latest version from the URL
LATEST_VERSION=$(echo "$REDIRECTED_URL" | grep -oP 'Bitwarden-\K[0-9]+\.[0-9]+\.[0-9]+(?=-amd64.deb)')

# Ensure we successfully retrieved the latest version number
if [[ -z "$LATEST_VERSION" ]]; then
    echo "❌ Failed to fetch the latest Bitwarden version. The website structure may have changed."
    exit 1
fi

echo "✅ Latest Bitwarden version: $LATEST_VERSION"

# Check if an update is needed
if [[ "$INSTALLED_VERSION" == "$LATEST_VERSION" ]]; then
    echo "👍 Bitwarden is already up to date. No update needed."
    exit 0
fi

echo "⬇️ Downloading Bitwarden $LATEST_VERSION..."
wget -O "$BITWARDEN_DEB" "$REDIRECTED_URL"

# Check if the download was successful
if [[ $? -ne 0 ]]; then
    echo "❌ Failed to download Bitwarden. Please check your internet connection."
    exit 1
fi

echo "✅ Download completed. Installing Bitwarden..."

# Install the package
sudo dpkg -i "$BITWARDEN_DEB"

# Fix missing dependencies if needed
if [[ $? -ne 0 ]]; then
    echo "⚠️ Fixing missing dependencies..."
    sudo apt-get install -f -y
fi

echo "🎉 Bitwarden has been updated successfully!"

# Cleanup
rm -f "$BITWARDEN_DEB"

How to Use

Save the script as update-bitwarden.sh in the user’s HOME directory.

Make it executable by executing the following command in the terminal:


chmod +x ~/update-bitwarden.sh

Run it manually:


~/update-bitwarden.sh

(Optional) Create a Desktop Shortcut
If you’d like a simple double-click shortcut, create a .desktop file, save it on the Desktop as Update-Bitwarden.desktop, and make it executable:

[Desktop Entry]
Version=1.0
Type=Application
Name=Update Bitwarden
Exec=gnome-terminal -- bash -c "$HOME/update-bitwarden.sh; echo ''; echo 'Press ENTER to exit...'; read"
Icon=utilities-terminal
Terminal=false
Categories=Utility;
StartupNotify=true

Save the script as Update-Bitwarden.desktop on the Desktop.

Make it executable by executing the following command in the terminal:


chmod +x ~/Desktop/Update-Bitwarden.desktop

With this setup, Bitwarden updates automatically with just a single click! No more manually checking for updates or downloading .deb files every time.

Hope this helps! Let me know if you have any improvements or suggestions. :rocket:

Happy vaulting! :closed_lock_with_key: