本教程适用于以下操作系统版本
- Debian 11 (Bullseye)
- Debian 10 (Buster)
在本页
- 先决条件
- 安装 Apache、MariaDB 和 PHP
- 为 Teampass 创建数据库
- 安装 Teampass
- 为 Teampass 创建 Apache 虚拟主机
- 访问 Teampass 网页界面
- 使用 Let's Encrypt SSL 保护 Teampass
- 结论
大多数用户在互联网上拥有大量社交媒体、电子邮件和其他账户。对任何人来说,管理他们所有的账户和密码都非常困难。这正是密码管理器派上用场的地方。Team pass 是一款开源密码管理器,可帮助你从集中位置存储和管理所有密码。它是一款协作式密码管理器,允许你与团队成员共享所有存储的密码。你还可以为每个用户设置访问权限,以控制他们只能访问指定的一组数据。
在本教程中,我将向你展示如何在 Debian 11 上使用 Apache 和 Let's Encrypt SSL 安装 Teampass 密码管理器。
先决条件
- 一台运行 Debian 11 的服务器。
- 一个指向你服务器 IP 的有效域名。
- 服务器上已配置 root 密码。
安装 Apache、MariaDB 和 PHP
首先,你需要在服务器上安装 Apache web 服务器、MariaDB 数据库服务器、PHP 及其他所需的扩展。你可以通过运行以下命令来安装所有这些:
apt-get install apache2 apache2-utils mariadb-server mariadb-client php7.4 libapache2-mod-php7.4 php7.4-mysql php-common php7.4-cli php7.4-common php7.4-json php7.4-opcache php7.4-readline php7.4-bcmath php7.4-curl php7.4-fpm php7.4-gd php7.4-xml php7.4-mbstring -y
所有软件包安装完成后,编辑 php.ini 文件并更改一些默认设置:
nano /etc/php/7.4/apache2/php.ini
更改以下设置:
max_execution_time = 60 date.timezone = Asia/Kolkata
保存并关闭文件,然后重启 Apache 服务以应用更改:
systemctl restart apache2
完成后,你可以继续下一步。
为 Teampass 创建数据库
Teampass 使用 MariaDB 作为数据库后端,因此你需要为 Teampass 创建一个数据库和用户。
首先,使用以下命令保护 MariaDB 安装并设置 MariaDB root 密码:
mysql_secure_installation
按照下面所示回答所有问题:
Enter current password for root (enter for none): Switch to unix_socket authentication [Y/n] n Change the root password? [Y/n] Y New password: Re-enter new password: Remove anonymous users? [Y/n] Y Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y
完成后,使用以下命令连接到 MariaDB:
mysql -u root -p
接下来,使用以下命令创建数据库和用户:
MariaDB [(none)]> create database teampass;
MariaDB [(none)]> grant all privileges on teampass.* to teampass@localhost identified by "password";
接下来,使用以下命令刷新权限并退出 MariaDB:
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit;
完成后,你可以继续下一步。
安装 Teampass
接下来,你需要从 Git 仓库下载最新版本的 Teampass。
首先,使用以下命令安装 git 软件包:
apt-get install git -y
接下来,将最新版本的 Teampass 下载到 Apache web 根目录:
cd /var/www/html/
git clone https://github.com/nilsteampassnet/TeamPass.git
接下来,使用以下命令更改所有权和权限:
chown -R www-data:www-data TeamPass
chmod -R 775 /var/www/html/TeamPass
完成后,你可以继续下一步。
为 Teampass 创建 Apache 虚拟主机
接下来,你需要创建一个 Apache 虚拟主机配置文件,以便在互联网上托管 Teampass。
nano /etc/apache2/sites-available/teampass.conf
添加以下行:
<VirtualHost *:80>
ServerAdmin
[email protected]
DocumentRoot /var/www/html/TeamPass
ServerName teampass.example.com
<Directory /var/www/html/TeamPass>
Options FollowSymlinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/teampass_error.log
CustomLog ${APACHE_LOG_DIR}/teampass_access.log combined
</VirtualHost>
保存并关闭文件,然后启用 Apache 虚拟主机并重启 Apache 服务以应用更改:
a2ensite teampass
systemctl restart apache2
你还可以使用以下命令验证 Apache 的状态:
systemctl status apache2
你将获得以下输出:
? apache2.service - The Apache HTTP Server
Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
Active: active (running) since Mon 2021-11-01 03:39:47 UTC; 5s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 20013 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 20017 (apache2)
Tasks: 6 (limit: 2341)
Memory: 14.1M
CPU: 95ms
CGroup: /system.slice/apache2.service
??20017 /usr/sbin/apache2 -k start
??20018 /usr/sbin/apache2 -k start
??20019 /usr/sbin/apache2 -k start
??20020 /usr/sbin/apache2 -k start
??20021 /usr/sbin/apache2 -k start
??20022 /usr/sbin/apache2 -k start
Nov 01 03:39:47 debian11 systemd[1]: Starting The Apache HTTP Server..
访问 Teampass 网页界面
现在,打开你的 web 浏览器,使用 URL http://teampass.example.com 访问 Teampass 网页界面。你应该会看到以下页面:

点击 LAUNCH 和 NEXT 按钮。你应该会看到服务器检查(Server checks)界面:

提供你的 Teampass 路径、网站 URL,然后点击 LAUNCH 和 NEXT 按钮。你应该会看到数据库连接(Database connection)界面:

提供你的数据库详细信息,然后点击 LAUNCH 和 NEXT 按钮。你应该会看到准备(preparation)界面:

提供你的管理员密码,然后点击 LAUNCH 和 NEXT 按钮。你应该会看到表创建(Table creation)界面:

点击 LAUNCH 和 NEXT 按钮。你应该会看到终结(Finalization)界面:

点击 LAUNCH 和 NEXT 按钮。安装成功完成后,你应该会看到以下界面:

现在,点击 Move to home page 按钮。你将被重定向到如下所示的 TeamPass 登录界面:

输入你的用户名 admin 以及你在安装过程中记下的密码,然后点击 Log In 按钮。你应该会在以下界面看到 TeamPass 仪表盘:

使用 Let's Encrypt SSL 保护 Teampass
首先,你需要在服务器上安装 Certbot Let's Encrypt 客户端。它用于为你的域名安装和管理 Let's Encrypt SSL 证书。运行以下命令安装 Certbot。
apt-get install python3-certbot-apache -y
Certbot 安装完成后,运行以下命令为你的网站下载并安装 Let's Encrypt SSL:
certbot --apache -d teampass.example.com
你需要提供有效的电子邮件地址并接受服务条款,如下所示:
Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator apache, Installer apache Enter email address (used for urgent renewal and security notices) (Enter 'c' to cancel): [email protected] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Please read the Terms of Service at https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must agree in order to register with the ACME server at https://acme-v02.api.letsencrypt.org/directory - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (A)gree/(C)ancel: A - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Would you be willing to share your email address with the Electronic Frontier Foundation, a founding partner of the Let's Encrypt project and the non-profit organization that develops Certbot? We'd like to send you email about our work encrypting the web, EFF news, campaigns, and ways to support digital freedom. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - (Y)es/(N)o: Y Obtaining a new certificate Performing the following challenges: http-01 challenge for teampass.example.com Enabled Apache rewrite module Waiting for verification... Cleaning up challenges Created an SSL vhost at /etc/apache2/sites-available/teampass-le-ssl.conf Enabled Apache socache_shmcb module Enabled Apache ssl module Deploying Certificate to VirtualHost /etc/apache2/sites-available/teampass-le-ssl.conf Enabling available site: /etc/apache2/sites-available/teampass-le-ssl.conf
接下来,你需要选择是否将 HTTP 流量重定向到 HTTPS,如下所示:
Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1: No redirect - Make no further changes to the webserver configuration. 2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for new sites, or if you're confident your site works on HTTPS. You can undo this change by editing your web server's configuration. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
输入 2 使所有请求重定向到安全的 HTTPS 访问,然后按 Enter 安装 Let's Encrypt SSL。安装成功完成后,你应该会看到以下输出:
Enabled Apache rewrite module Redirecting vhost in /etc/apache2/sites-enabled/teampass.conf to ssl vhost in /etc/apache2/sites-available/teampass-le-ssl.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully enabled https://teampass.example.com You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=teampass.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/teampass.example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/teampass.example.com/privkey.pem Your cert will expire on 2022-01-30. To obtain a new or tweaked version of this certificate in the future, simply run certbot again with the "certonly" option. To non-interactively renew *all* of your certificates, run "certbot renew" - Your account credentials have been saved in your Certbot configuration directory at /etc/letsencrypt. You should make a secure backup of this folder now. This configuration directory will also contain certificates and private keys obtained by Certbot so making regular backups of this folder is ideal. - If you like Certbot, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le
此时,你的网站已受 Let's Encrypt SSL 保护。现在你可以使用 HTTPS 协议安全地访问它。
结论
恭喜!你已在 Debian 11 上使用 Apache 和 Let's Encrypt SSL 成功安装了 Teampass 密码管理器。现在你可以通过基于 web 的界面管理所有凭据并与团队共享。