放弃付费1Password改用免费开源的bitwarden_rs自建密码管理系统-安装,使用和备份

1Password是去年搞活动入手的,之前一直在用KeePass,但是KeePass在浏览器和安卓手机上使用体验不是很好,用过了1Password之后发现密码管理服务做得真的是非常好了。不过有一个不好的地方就是1Password太贵了,一年至少需要35美元。

而且1Password还只能使用信用卡付款,像Paypal也不支持,这让很多想尝试1Password的朋友“望而却步”了。这篇文章主要分享一下在功能上和使用体验上媲美1Password的免费开源密码管理系统Bitwarden,自建Bitwarden,再也不用担心1Password删库“跑路”了。
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/a6624baafecf4f4aa6466abdd213c8eb",/>

如果你是一名站长的话,其实很多的付费服务都是可以通过免费开源的程序来自我搭建的,例如:
<ol,start="1"> ,

 

  • 自建CDN加速-Nginx反向绑定,缓存加速,自动更新缓存和获取真实IP


 

,

 

  • 自建RSS阅读器Tiny,Tiny,RSS安装和配置自动更新,全文RSS,更换主题,手机RSS登录


 

,

 

  • Aria2离线下载和在线播放-整合KodExplorer,FileManager,Nextcloud和,Plex系统


 

<h2,class="ftwp-heading">一、bitwarden_rs安装教程

网站:
<ol,start="1"> ,

 

  • 官网:https://bitwarden.com/


 

,

 

  • 第三方项目:https://github.com/dani-garcia/bitwarden_rs


 

Bitwarden官方推荐使用Docker镜像安装,但是Bitwarden,服务器使用,.Net,开发,如果使用,Docker,来部署,镜像体积过大;此外它使用,MSSQL,数据库,部署这个数据库对服务器配置要求比较高。而是bitwarden_rs是第三方开发的Bitwarden安装镜像。
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/fa0c775fe6fa4add9c9451f2080ac57f",/>

bitwarden_rs采用,Rust,实现了,Bitwarden服务器,这个实现更进一步降低了对机器配置的要求,并且,Docker,镜像体积很小,部署非常方便。此外,官方服务器中需要付费订阅的一些功能,在这个实现中是免费的。挖站否在512MB内存上机子完美运行bitwarden_rs。
<h3,class="ftwp-heading">1.1,安装前准备

一台VPS主机。bitwarden_rs使用Docker镜像来安装,需要使用一台VPS主机,配置不用太高,我自己用512MB内存也能跑起来,而且非常地流畅。购买VPS主机请参考:VPS主机排行榜单。
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/11e9aa43da3a4ba58f755f6f25a3379c",/>

一个域名。虽然有市面上有少的免费域名,但是建议还是使用付费的域名,密码这个东西比较重要,一旦确定要自建密码管理系统的话就要保证可以长期使用。参考:域名服务。
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/bfb620e4a1804345abf45cb1b976c673",/>

<h3,class="ftwp-heading">1.2,安装好Docker

你需要先安培安装,Docker,CE,(社区版)和Docker,Compose,以下命令是基于Debian系统的演示,如果你是CentOS、Ubuntu,请参考官网:
<blockquote,class="wp-block-quote">安装,Docker,CE,(社区版):https://docs.docker.com/install/linux/docker-ce/ubuntu/

安装,Docker,Compose:https://docs.docker.com/compose/install/#install-compose

Debian系统安装Docker,CE,和Docker,Compose如下:
<ol,start="1"> ,

 

  • #卸载


 

,

 

  • sudo,apt-get,remove,docker,docker-engine,docker.io,containerd,runc


 

,

 

  • #SET,UP,THE,REPOSITORY


 

,

 

  • sudo,apt-get,update


 

,

 

  • sudo,apt-get,install,


 

,

 

  • apt-transport-https,


 

,

 

  • ca-certificates,


 

,

 

  • curl,


 

,

 

  • gnupg2,


 

,

 

  • software-properties-common


 

,

 

  • curl,-fsSL,https://download.docker.com/linux/debian/gpg,|,sudo,apt-key,add,-


 

,

 

  • #检测是否安装成功


 

,

 

  • sudo,apt-key,fingerprint,0EBFCD88


 

,

 

  • #有以下输出就表示成功添加Docker’s,official,GPG,key:


 

,

 

  • root@hostfbc9e58d73:~#,sudo,apt-key,fingerprint,0EBFCD88


 

,

 

  • pub,rsa4096,2017-02-22,[SCEA]


 

,

 

  • 9DC8,5822,9FC7,DD38,854A,E2D8,8D81,803C,0EBF,CD88


 

,

 

  • uid,[,unknown],Docker Release (CE,deb),<docker@docker.com>


 

,

 

  • sub,rsa4096,2017-02-22,[S]


 

,

 

  • #添加stable,repository


 

,

 

  • sudo,add-apt-repository,


 

,

 

  • "deb,[arch=amd64],https://download.docker.com/linux/debian,


 

,

 

  • $(lsb_release,-cs),


 

,

 

  • stable"


 

,

 

  • #开始安装


 

,

 

  • sudo,apt-get,update


 

,

 

  • sudo,apt-get,install,docker-ce,docker-ce-cli,containerd.io


 

,

 

  • #验证,Docker,Engine,-,Community是否安装正确


 

,

 

  • sudo,docker,run,hello-world


 

,

 

  • #有以下输出就表示正确安装


 

,

 

  • root@hostfbc9e58d73:~#,sudo,docker,run,hello-world


 

,

 

  • Unable,to,find,image,'hello-world:latest',locally


 

,

 

  • latest:,Pulling,from,library/hello-world


 

,

 

  • 1b930d010525:,Pull,complete


 

,

 

  • Digest:,sha256:b8ba256769a0ac28dd126d584e0a2011cd2877f3f76e093a7ae560f2a5301c00


 

,

 

  • Status:,Downloaded,newer,image,for,hello-world:latest


 

,

 

  • Hello,from,Docker!


 

,

 

  • This,message,shows,that,your,installation,appears,to,be,working,correctly.


 

,

 

  • To,generate,this,message,,Docker,took,the,following,steps:


 

,

 

  • 1.,The,Docker,client,contacted,the,Docker,daemon.


 

,

 

  • 2.,The,Docker,daemon,pulled,the,"hello-world",image,from,the,Docker,Hub.


 

,

 

  • (amd64)


 

,

 

  • 3.,The,Docker,daemon,created,a,new,container,from,that,image,which,runs,the


 

,

 

  • executable,that,produces,the,output,you,are,currently,reading.


 

,

 

  • 4.,The,Docker,daemon,streamed,that,output,to,the,Docker,client,,which,sent,it


 

,

 

  • to,your,terminal.


 

,

 

  • To,try,something,more,ambitious,,you,can,run,an,Ubuntu,container,with:


 

,

 

  • $,docker,run,-it,ubuntu,bash


 

,

 

  • Share,images,,automate,workflows,,and,more,with,a,free,Docker,ID:


 

,

 

  • https://hub.docker.com/


 

,

 

  • For,more,examples,and,ideas,,visit:


 

,

 

  • https://docs.docker.com/get-started/


 

,

 



 

,

 



 

,

 

  • #安装,Docker,Compose


 

,

 

  • sudo,curl,-L,"https://github.com/docker/compose/releases/download/1.24.1/docker-compose-$(uname,-s)-$(uname,-m)",-o,/usr/local/bin/docker-compose


 

,

 

  • sudo,chmod,+x,/usr/local/bin/docker-compose


 

,

 

  • #检测是否安装成功


 

,

 

  • docker-compose,--version


 

,

 

  • #有输出即表示成功


 

,

 

  • docker-compose,version,1.24.1,,build,4667896b


 

,

 

  • #如果提示命令不存在,可以手动创建链接


 

,

 

  • sudo,ln,-s,/usr/local/bin/docker-compose,/usr/bin/docker-compose


 

<h3,class="ftwp-heading">1.3,安装好Nginx

bitwarden_rs官方可以选择使用Caddy来搭建Web服务,但是这里使用Nginx来搭建Web。主要原因有:一你的VPS可以用来建站,bitwarden与你的网站不会相冲突;二Nginx安装和备份的教程多,使用起来简单。推荐使用Oneinstack或者LNMP一键脚本,当然你也可以使用VPS主机面板。
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/cadbd0dc6ee048afaafca5f09fdbf2b4",/>

<h3,class="ftwp-heading">1.4,bitwarden_rs安装

bitwarden_rs安装只需要一句代码就可以搞定:
<ol,start="1"> ,

 

  • docker,pull,bitwardenrs/server:latest


 

<h2,class="ftwp-heading">二、bitwarden_rs配置方法

挖站否用的启用命令如下(相关的解释如下):
<ol,start="1"> ,

 

  • docker,run,-d,--name,bitwarden,


 

,

 

  • -e,SIGNUPS_ALLOWED=true,


 

,

 

  • -e,WEBSOCKET_ENABLED=true,


 

,

 

  • -e,LOG_FILE=/data/bitwarden.log,


 

,

 

  • -p,8880:80,


 

,

 

  • -p,3012:3012,


 

,

 

  • -v,/bw-data/:/data/,


 

,

 

  • bitwardenrs/server:latest


 

<h3,class="ftwp-heading">2.1,启动bitwarden

启动bitwarden也很简单,我们只需要执行以下代码即可:
<ol,start="1"> ,

 

  • docker,run,-d,--name,bitwarden,-v,/bw-data/:/data/,-p,8880:80,bitwardenrs/server:latest


 

,

 

  • #或者直接使用80端口,不过这样的话你原来建有网站的话80端口就被占用了。


 

,

 

  • docker,run,-d,--name,bitwarden,-v,/bw-data/:/data/,-p,80:80,bitwardenrs/server:latest


 

<h3,class="ftwp-heading">2.2,设置Nginx

配置Nginx反向代理目的是为了可以使用域名来访问bitwarden,首先我们用Oneinstack安装好了Nginx并且配置好了域名、SSL等,现在打开Nginx域名配置文件,参考下方的内容直接替换即可:
<ol,start="1"> ,

 

  • server,{


 

,

 

  • listen,80;


 

,

 

  • listen,443,ssl,http2;


 

,

 

  • ssl_certificate,/usr/local/nginx/conf/ssl/mima.wzfou.net.crt;


 

,

 

  • ssl_certificate_key,/usr/local/nginx/conf/ssl/mima.wzfou.net.key;


 

,

 

  • ssl_protocols,TLSv1,TLSv1.1,TLSv1.2,TLSv1.3;


 

,

 

  • ssl_ciphers,TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;


 

,

 

  • ssl_prefer_server_ciphers,on;


 

,

 

  • ssl_session_timeout,10m;


 

,

 

  • ssl_session_cache,builtin:1000,shared:SSL:10m;


 

,

 

  • ssl_buffer_size,1400;


 

,

 

  • add_header,Strict-Transport-Security,max-age=15768000;


 

,

 

  • ssl_stapling,on;


 

,

 

  • ssl_stapling_verify,on;


 

,

 

  • server_name,mima.wzfou.net;


 

,

 

  • if ($ssl_protocol,=,""),{,return,301,https://$host$request_uri;,}


 

,

 



 

,

 

  • client_max_body_size,128M;


 

,

 

  • location,/,{


 

,

 

  • proxy_set_header,Host,'mima.wzfou.net';


 

,

 

  • proxy_pass,http://127.0.0.1:8880;


 

,

 

  • proxy_redirect,off;


 

,

 

  • proxy_set_header,X-Real-IP,$remote_addr;


 

,

 

  • proxy_set_header,X-Forwarded-For,$proxy_add_x_forwarded_for;


 

,

 

  • }


 

,

 

  • location,/notifications/hub,{


 

,

 

  • proxy_pass,http://127.0.0.1:3012;


 

,

 

  • proxy_set_header,Upgrade,$http_upgrade;


 

,

 

  • proxy_set_header,Connection,"upgrade";


 

,

 

  • }


 

,

 



 

,

 

  • location,/notifications/hub/negotiate,{


 

,

 

  • proxy_pass,http://127.0.0.1:8880;


 

,

 

  • }


 

,

 



 

,

 



 

,

 

  • }


 

重启Nginx,刷新一下浏览器,你可以看到bitwarden已经可以正常访问了。
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/34bded2deccf42f09a0d4e9c16afe246",/>

<h3,class="ftwp-heading">2.3,禁止注册

为了保证bitwarden服务器的稳定,你可以禁止bitwarden注册新用户(这一项可以放在最后,否则你自己都无法注册了)。禁止新用户注册:
<pre,class="source-code">docker,run,-d,--name,bitwarden,
,,-e,SIGNUPS_ALLOWED=false,
,,-v,/bw-data/:/data/,
,,-p,80:80,
,,bitwardenrs/server:latest


<h3,class="ftwp-heading">2.4,关闭重启

启动和关闭:

stopped,by,docker,stop,bitwarden,,a,reboot,or,any,other,reason,you,can,just,start,it,up,again,by,using
<ol,start="1"> ,

 

  • docker,start,bitwarden


 

<h3,class="ftwp-heading">2.5,升级

you,just,need,to,pull,the,latest,image,,stop,and,rm,the,current,container,and,then,start,a,new,one,the,same,way,as,before:
<pre,class="source-code">#,Pull,the,latest,version
docker,pull,bitwardenrs/server:latest

#,Stop,and,remove,the,old,container
docker,stop,bitwarden
docker,rm,bitwarden

#,Start,new,container,with,the,data,mounted
docker,run,-d,--name,bitwarden,-v,/bw-data/:/data/,-p,80:80,bitwardenrs/server:latest


<pre,class="source-code">#或者是,

<pre,class="source-code">docker,run,-d,--name,bitwarden,-v,/bw-data/:/data/,-p,8880:80,bitwardenrs/server:latest

<h3,class="ftwp-heading">2.6,其它设置

启用日志记录:
<ol,start="1"> ,

 

  • -e,LOG_FILE=/data/bitwarden.log


 

启用WebSocket,notifications:
<ol,start="1"> ,

 

  • -e,WEBSOCKET_ENABLED=true


 

<h2,class="ftwp-heading">三、Docker,Compose配置

这一步可选。使用Docker,Compose配置可以方便你管理Docker,不用也可以。,在bitwarden目录创建docker-compose.yml文件
<ol,start="1"> ,

 

  • vim,docker-compose.yml


 

在docker-compose.yml写入一下配置,参考官方wiki(https://github.com/dani-garcia/bitwarden_rs/wiki/Using-Docker-Compose)
<ol,start="1"> ,

 

  • version:,"3"


 

,

 



 

,

 

  • services:


 

,

 

  • bitwarden:


 

,

 

  • image:,bitwardenrs/server


 

,

 

  • container_name:,bitwardenrs


 

,

 

  • restart:,always


 

,

 

  • ports:


 

,

 

  • -,"127.0.0.1:8880:80",#将8880端口映射到镜像80端口


 

,

 

  • -,"127.0.0.1:3012:3012"


 

,

 

  • volumes:


 

,

 

  • -,./bw-data:/data


 

,

 

  • environment:


 

,

 

  • WEBSOCKET_ENABLED:,"true",#开启WebSocket


 

,

 

  • SIGNUPS_ALLOWED:,"true",#开启注册,自己注册后改成fale


 

,

 

  • WEB_VAULT_ENABLED:,"true",#web客户端


 

运行服务
<ol,start="1"> ,

 

  • docker-compose,up,-d,#运行服务


 

,

 

  • docker-compose,down,#关闭服务


 

,

 

  • docker-compose,restart,#重启服务


 

<h2,class="ftwp-heading">四、bitwarden管理密码

<h3,class="ftwp-heading">4.1,网页版bitwarden

网页版的bitwarden管理密码也是非常地方便。以下是bitwarden的界面,有中文:(点击放大)
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/e524725aa64f4939b3d490efad12e36a",/>

这是bitwarden的设置页面。
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/b855606a34c44f048130ea638ff49260",/>

可以自己设置两步验证,加强安全性。
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/cb76918fb8724f28bafa738a7f257640",/>

<h3,class="ftwp-heading">4.2,浏览器bitwarden

bitwarden提供了Chrome、Firefox等浏览器插件,直接安装就可以启用。
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/c47f9afef7f3403ea8475e7998203103",/>

在插件设置中填入你自己的bitwarden地址(否则是进入到官方的地址)
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/979d62fed61648f4937658dd93350715",/>

bitwarden的Chrome浏览器插件界面如下:(点击放大)
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/a328fcadeef84128973a66daddf327d0",/>

bitwarden浏览器设置页面。
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/a8c6e5a36eb545698c1a55934b2fef3f",/>

bitwarden浏览器插件支持手动添加登录。
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/f199d49c8e5a4127b579b08660442680",/>

同时,bitwarden浏览器插件也会提示保存密码。如下图:
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/857c86fe21b34e94bb3b6cd10e50a000",/>

bitwarden浏览器插件还有一个非常好用的功能就是自动加载密码。
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/7fc9f250c560455091c3da03aec71a15",/>

<h3,class="ftwp-heading">4.3,bitwarden电脑客户端

bitwarden有电脑客户端,操作类似于网页版。
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/de761cfbafb844768076fbeeae22e669",/>

bitwarden用起来和1Password一样,如果你是1Password重度用户不会陌生的。
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/4c9bbdde8543433ab299e9252a8296b5",/>

<h3,class="ftwp-heading">4.4,bitwarden手机客户端

bitwarden手机APP用户起来非常地方便,如下图:
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/cff5c4f7a162491c811c18dfae3c1b94",/>

bitwarden支持指纹解锁,以及自动填充密码等。
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/5fd20d043df146e5ae6efe8596036da4",/>

<h2,class="ftwp-heading">五、bitwarden导入1Password

bitwarden支持市面上绝大多数的密码管理器的数据导入,例如KeePass、Enpass、Avast,Passwords、LastPass、Chrome、SafeInCloud、Zoho,Vault等:
<ol,start="1"> ,

 

  • https://help.bitwarden.com/article/import-data/


 

如果是导入1Password,先打开你的1Password电脑桌面客户端,选择导出。
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/00e1b56b9793448b928abb0fccc6b2e8",/>

格式选择CSV,打开你的bitwarden网页版,点击工具下的数据导入。
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/466fb147bb8946e79e7f8a61789779ba",/>

选择1Password类型,点击导入即可。
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/ffe67c39ef0a4351bd389a76330a805b",/>

<h2,class="ftwp-heading">六、bitwarden备份与恢复

<h3,class="ftwp-heading">6.1,手动备份

bitwarden备份最关键的就是sqlite3数据库文件了,你可以直接进入到bw-data目录下,将sqlite3数据库保存下来。当然你也可以将bw-data目录下所有的包括附件文件夹、图标缓存文件夹、密钥等文件备份下来。
<div,class="pgc-img"><img,src="http://pb3.pstatp.com/large/pgc-image/a199a34eb4b44974b0c191126c685ade",/>

<h3,class="ftwp-heading">6.2,自动备份

利用定时任务执行bitwarden备份,首先新建一个文件夹:mkdir,/bw-data/db-backup,然后执行数据库备份任务。代码如下(关于定时任务说明参考:Linux,Crontab命令定时任务基本语法与操作教程):
<ol,start="1"> ,

 

  • sqlite3,/bw-data/db.sqlite3,".backup,'/bw-data/db-backup/backup.sqlite3'"


 

<h3,class="ftwp-heading">6.3,恢复备份

bitwarden要恢复备份的话也很简单,直接将sqlite3数据库重写替换就可以了,其它的几个文件夹可以覆盖,也可以保留新的,不影响。如果你的数据库路径与原来的不一致,可以手动指定,代码示例:
<ol,start="1"> ,

 

  • docker,run,-d,--name,bitwarden,


 

,

 

  • -e,DATABASE_URL=/database/bitwarden.sqlite3,


 

,

 

  • -v,/bw-data/:/data/,


 

,

 

  • -v,/bw-database/:/database/,


 

,

 

  • -p,80:80,


 

,

 

  • bitwardenrs/server:latest


 

<h2,class="ftwp-heading">七、总结

bitwarden作为一款开源的密码管理器,其本身支持平台之多,功能之全面,是替代1Password的理想品。bitwarden安装简单,采用Docker镜像,特别适合已经有了VPS建站的朋友,在不影响建站的情况下正常使用bitwarden。

bitwarden可以支持多用户注册使用,如果想要让bitwarden发送邮件的话,可以使用SMTP发邮件,参考代码如下:
<ol,start="1"> ,

 

  • docker,run,-d,--name,bitwarden,


 

,

 

  • -e,SMTP_HOST=<smtp.domain.tld>,


 

,

 

  • -e,SMTP_FROM=<bitwarden@domain.tld>,


 

,

 

  • -e,SMTP_PORT=587,


 

,

 

  • -e,SMTP_SSL=true,


 

,

 

  • -e,SMTP_USERNAME=<username>,


 

,

 

  • -e,SMTP_PASSWORD=<password>,


 

,

 

  • -v,/bw-data/:/data/,


 

,

 

  • -p,80:80,


 

,

 

  • bitwardenrs/server:latest


 
    A+
发布日期:2020年4月17日  所属分类: 实用技术
标签: