天天看點

如何在Debian 11上安裝開源的Bitwarden密碼管理器

Bitwarden 是一個免費的開源密碼管理器,可将網站憑據存儲在加密的保險庫中,它允許您存儲所有登入憑據,并使它們在所有裝置之間保持同步。

Bitwarden專為個人、團隊和商業組織設計,可以從一個集中位置管理他們的憑證,Bitwarden 為台式 PC 以及智能手機和平闆電腦提供用戶端應用程式。

Bitwarden還提供了一個密碼生成器,用于生成強大而安全的密碼。

先決條件

  • 運作 Ubuntu 20.04 的伺服器。
  • 在伺服器上配置了 root 密碼。

安裝 Docker 和 Docker Compose

Bitwarden 提供了一個免費版本,您可以使用 Docker 安裝它,預設情況下,Debian 11 預設存儲庫中不包含最新版本的 Docker,是以,您需要從 Docker 的官方存儲庫安裝它。

首先,使用以下指令安裝所有必需的依賴項:

apt-get install apt-transport-https ca-certificates curl gnupg-agent software-properties-common      

安裝所有依賴項後,使用以下指令下載下傳并添加 GPG 密鑰:

curl -fsSL https://download.docker.com/linux/debian/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg      

接下來,使用以下指令将 Docker CE 存儲庫添加到 APT:

echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/debian $(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list      

接下來,使用以下指令更新存儲庫并安裝 Docker CE:

apt-get update -y 
apt-get install docker-ce docker-ce-cli containerd.io -y      

安裝完成後,您可以使用以下指令驗證 Docker CE 版本:

docker --version      

您将獲得以下輸出:

Docker version 20.10.9, build c2ea9bc      

您還可以使用以下指令檢查 Docker 的狀态:

systemctl status docker      

您應該看到以下輸出:

? docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
     Active: active (running) since Sat 2021-10-25 09:33:15 UTC; 14min ago
TriggeredBy: ? docker.socket
       Docs: https://docs.docker.com
   Main PID: 11656 (dockerd)
      Tasks: 29
     Memory: 1.0G
     CGroup: /system.slice/docker.service
             ??11656 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
             ??27717 /usr/bin/docker-proxy -proto tcp -host-ip 0.0.0.0 -host-port 80 -container-ip 172.18.0.5 -container-port 8052

Oct 25 09:33:14 ubuntu2004 dockerd[11656]: time="2021-10-03T09:33:14.865741428Z" level=info msg="Default bridge (docker0) is assigned with an >
Oct 25 09:33:14 ubuntu2004 dockerd[11656]: time="2021-10-03T09:33:14.951326143Z" level=info msg="Loading containers: done."
Oct 25 09:33:14 ubuntu2004 dockerd[11656]: time="2021-10-03T09:33:14.974570590Z" level=info msg="Docker daemon" commit=4484c46d9d graphdriver(>
Oct 25 09:33:14 ubuntu2004 dockerd[11656]: time="2021-10-03T09:33:14.974729712Z" level=info msg="Daemon has completed initialization"
Oct 25 09:33:15 ubuntu2004 dockerd[11656]: time="2021-10-03T09:33:15.030128906Z" level=info msg="API listen on /run/docker.sock"
Oct 25 09:33:15 ubuntu2004 systemd[1]: Started Docker Application Container Engine.
Oct 25 09:45:52 ubuntu2004 dockerd[11656]: time="2021-10-03T09:45:52.583474433Z" level=info msg="ignoring event" module=libcontainerd namespac>
Oct 25 09:45:52 ubuntu2004 dockerd[11656]: time="2021-10-03T09:45:52.619380786Z" level=info msg="ignoring event" module=libcontainerd namespac>
Oct 25 09:45:52 ubuntu2004 dockerd[11656]: time="2021-10-03T09:45:52.635359740Z" level=info msg="ignoring event" module=libcontainerd namespac>
Oct 25 09:45:52 ubuntu2004 dockerd[11656]: time="2021-10-03T09:45:52.637507396Z" level=info msg="ignoring event" module=libcontainerd namespac      

接下來,使用以下指令下載下傳最新版本的 Docker Composer:

wget https://github.com/docker/compose/releases/download/v2.0.1/docker-compose-linux-x86_64      

接下來,使用以下指令将下載下傳的二進制檔案複制到系統路徑:

mv docker-compose-linux-x86_64 /usr/bin/docker-compose      

接下來,為 Docker Compose 二進制檔案設定執行權限:

chmod 755 /usr/bin/docker-compose      

在 Debian 11 上安裝 Bitwarden

首先,轉到 Bitwarden 網站并提供您的電子郵件位址,如下所示:

主機安裝密鑰

接下來,單擊送出按鈕。您将在以下螢幕上獲得安裝 ID 和密鑰。記下它們,因為您稍後在安裝過程中需要它們。

現在,使用以下指令下載下傳 Bitwarden 安裝腳本:

curl -Lso bitwarden.sh https://go.btwrdn.co/bw-sh      

下載下傳腳本後,使用以下指令設定執行權限:

chmod +x bitwarden.sh      

接下來,使用以下指令開始安裝:

./bitwarden.sh install      

您将被要求提供您的域名或 IP 位址和保管庫,如下所示:

_     _ _                         _            
| |__ (_) |___      ____ _ _ __ __| | ___ _ __  
| '_ \| | __\ \ /\ / / _` | '__/ _` |/ _ \ '_ \ 
| |_) | | |_ \ V  V / (_| | | | (_| |  __/ | | |
|_.__/|_|\__| \_/\_/ \__,_|_|  \__,_|\___|_| |_|

Open source password management solutions
Copyright 2015-2021, 8bit Solutions LLC
https://bitwarden.com, https://github.com/bitwarden

===================================================

bitwarden.sh version 1.43.0
Docker version 20.10.9, build c2ea9bc
docker-compose version 1.25.0, build unknown

(!) Enter the domain name for your Bitwarden instance (ex. bitwarden.example.com): 69.28.84.207

(!) Do you want to use Let's Encrypt to generate a free SSL certificate? (y/n): n

(!) Enter the database name for your Bitwarden instance (ex. vault): vault      

提供所有必需的資訊,然後按Enter。系統會要求您提供安裝 ID 和密鑰,如下所示:

Digest: sha256:29bd0777de8b902bd26a67f74c832c8032f1bea41e716277a98f7d439a8f2912
Status: Downloaded newer image for bitwarden/setup:1.43.0
docker.io/bitwarden/setup:1.43.0

(!) Enter your installation id (get at https://bitwarden.com/host): xxxxxxx-xxxxxx-xxxx-xxxx-xxxxxxxxxx

(!) Enter your installation key: xxxxxxxxxxx

(!) Do you have a SSL certificate to use? (y/n): n

(!) Do you want to generate a self-signed SSL certificate? (y/n): y      

提供所有必需的資訊,然後按Enter開始安裝。安裝完成後,您将獲得以下輸出:

Generating self signed SSL certificate.
Generating a RSA private key
.....++++
...........................................................................................................................++++
writing new private key to '/bitwarden/ssl/self/69.28.84.207/private.key'
-----
Generating key for IdentityServer.
Generating a RSA private key
........................................................................................................................................................................++++
..............................................................................................................++++
writing new private key to 'identity.key'
-----

!!!!!!!!!! WARNING !!!!!!!!!!
You are using an untrusted SSL certificate. This certificate will not be 
trusted by Bitwarden client applications. You must add this certificate to 
the trusted store on each device or else you will receive errors when trying 
to connect to your installation.

Building nginx config.
Building docker environment files.
Building docker environment override files.
Building FIDO U2F app id.
Building docker-compose.yml.

Installation complete

If you need to make additional configuration changes, you can modify
the settings in `./bwdata/config.yml` and then run:
`./bitwarden.sh rebuild` or `./bitwarden.sh update`      

下一步,運作:

./bitwarden.sh start`      

您将獲得以下輸出:

_     _ _                         _            
| |__ (_) |___      ____ _ _ __ __| | ___ _ __  
| '_ \| | __\ \ /\ / / _` | '__/ _` |/ _ \ '_ \ 
| |_) | | |_ \ V  V / (_| | | | (_| |  __/ | | |
|_.__/|_|\__| \_/\_/ \__,_|_|  \__,_|\___|_| |_|

Open source password management solutions
Copyright 2015-2021, 8bit Solutions LLC
https://bitwarden.com, https://github.com/bitwarden

===================================================

bitwarden.sh version 1.43.0
Docker version 20.10.9, build c2ea9bc
docker-compose version 1.25.0, build unknown

Pulling mssql         ... done
Pulling web           ... done
Pulling attachments   ... done
Pulling api           ... done
Pulling identity      ... done
Pulling sso           ... done
Pulling admin         ... done
Pulling portal        ... done
Pulling icons         ... done
Pulling notifications ... done
Pulling events        ... done
Pulling nginx         ... done

Creating network "docker_default" with the default driver
Creating network "docker_public" with the default driver
Creating bitwarden-web           ... done
Creating bitwarden-mssql         ... done
Creating bitwarden-sso           ... done
Creating bitwarden-icons         ... done
Creating bitwarden-attachments   ... done
Creating bitwarden-identity      ... done
Creating bitwarden-notifications ... done
Creating bitwarden-api           ... done
Creating bitwarden-events        ... done
Creating bitwarden-admin         ... done
Creating bitwarden-portal        ... done
Creating bitwarden-nginx         ... done
1.43.0: Pulling from bitwarden/setup
Digest: sha256:29bd0777de8b902bd26a67f74c832c8032f1bea41e716277a98f7d439a8f2912
Status: Image is up to date for bitwarden/setup:1.43.0
docker.io/bitwarden/setup:1.43.0


Bitwarden is up and running!
===================================================

visit https://69.28.84.207
to update, run `./bitwarden.sh updateself` and then `./bitwarden.sh update`      

完成後,您可以繼續下一步。

通路 Bitwarden Web 界面

現在,打開您的網絡浏覽器并使用 URL https://your-server-ip通路 Bitwarden 網絡界面。您将獲得以下頁面:

如何在Debian 11上安裝開源的Bitwarden密碼管理器

單擊建立帳戶按鈕。您将獲得以下頁面:

如何在Debian 11上安裝開源的Bitwarden密碼管理器

提供您的電子郵件、姓名、主密碼,然後單擊“送出”按鈕。您将看到 Bitwarden 登入螢幕:

如何在Debian 11上安裝開源的Bitwarden密碼管理器

提供您的電子郵件位址、密碼,然後單擊登入按鈕。您應該會在以下頁面上看到 Bitwarden 儀表闆:

結論