一、前言
Bitwarden 作为一个开源的密码管理器,有着丰富的社区生态,我们可以将它轻松部署在自己的云服务器、单板机上,确保自己的密码库绝对安全。本教程会提供 Bitwarden 自托管方案,同时给出数据库的备份方案
二、部署 Vaultwarden & Backup 服务
1. 安装 Docker Engine
- 通过 SSH 连接到你的服务器,执行以下命令:
sudo apt update && sudo apt install curl -y
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh ./get-docker.sh
sudo usermod -aG docker $USER
2. 部署 Vaultwarden 备份服务
2.1 获取 Google Drive API 密钥
我这里以 Google Drive 为例,你也可以使用阿里云盘等云服务,更多云盘的实现可以参考 rclone 官方文档。
首先需要在 Google Cloud Console 创建一个项目,并进入 API 与服务板块,点击启动 API 和服务:

创建 Google Drive API
搜索 Google Drive API 并添加,然后进入“凭证”界面,配置权限请求界面,用户类型记得选择“外部”,其余没有什么特别的,正常填写即可:

配置权限请求界面
点击“客户端”,创建一个桌面应用类型的客户端,名称随意:

创建 OAuth 客户端
创建完成后,切记将 客户端 ID 和 客户端密钥 复制到安全地方,待会需要使用:

Google Drive 客户端 ID 和密钥
最后,在目标对象中将自己添加到测试用户中即可大功告成:

将自己添加到测试用户中
2.2 配置 Rclone 服务
在你的云服务器终端执行:
docker run --rm -it \
--mount type=volume,source=vaultwarden-rclone-data,target=/config/ \
ttionya/vaultwarden-backup:latest \
rclone config
进入 Rclone 交互式命令界面后,请根据自身需求进行选择,我的配置如下:
Option service_account_file.
Service Account Credentials JSON file path.
Leave blank normally.
Needed only if you want use SA instead of interactive login.
Leading `~` will be expanded in the file name as will environment variables such as `${RCLONE_CONFIG_DIR}`.
Enter a value. Press Enter to leave empty.
service_account_file>
Edit advanced config?
y) Yes
n) No (default)
y/n> n
Use web browser to automatically authenticate rclone with remote?
* Say Y if the machine running rclone has a web browser you can use
* Say N if running rclone on a (remote) machine without web browser access
If not sure try Y. If Y failed, try N.
y) Yes (default)
n) No
y/n> n
Option config_token.
For this to work, you will need rclone available on a machine that has
a web browser available.
For more help and alternate methods see: https://rclone.org/remote_setup/
Execute the following on the machine with the web browser (same rcloneversion recommended): rclone authorize "drive" "eyJjbGllbnRfaWQiOiI2NTYxMjcxMDU1MS02OGZodGI4N2k3MDUwNDNoa2htNnQ1OWR0Y2tsaW1wdS5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbSIsImNsaWVudF9zZWNyZXQiOiJHT0NTUFgtdHdwV2tSVHYxdi1GNFlwTDl4Z0FhdkgyMnNCUiIsInNjb3BlIjoiZHJpdmUifQ"Then paste the result.Enter a value.config_token>
RSS
Explore more posts
Get updates via RSS, or browse related posts on the site.


