如何在 Ubuntu 20.04 LTS 上安装 Teampass 密码管理器

在本教程中,我们将向您展示如何在 Ubuntu 20.04 LTS 上安装 Teampass 密码管理器。 对于那些不知道的人,TeamPass 是一款开源密码管理器,可帮助您从中央位置存储和管理所有密码。 它是一个协作密码管理器,可让您与团队成员共享所有存储的密码。 TeamPass 使用 MySQL/MariaDB 存储密码,并提供了一个强大的工具来自定义密码访问 Teampass 是高度可定制的,并提供了许多选项来根据您的需要进行自定义。 它使用 Defuse PHP 加密库来保护您的数据和用户。

本文假设您至少具备 Linux 的基本知识,知道如何使用 shell,最重要的是,您将网站托管在自己的 VPS 上。 安装非常简单,假设您在 root 帐户下运行,如果不是,您可能需要添加 ‘sudo‘ 到命令以获取 root 权限。 我将向您展示在 Ubuntu 20.04 (Focal Fossa) 上逐步安装 Teampass 密码管理器。 对于 Ubuntu 18.04、16.04 和任何其他基于 Debian 的发行版,如 Linux Mint,您可以按照相同的说明进行操作。

在 Ubuntu 20.04 LTS Focal Fossa 上安装 Teampass 密码管理器

步骤 1. 首先,通过运行以下命令确保所有系统包都是最新的 apt 终端中的命令。

sudo apt update sudo apt upgrade

步骤 2. 安装 LAMP 堆栈。

需要 Ubuntu 20.04 LAMP 服务器。 如果您没有安装 LAMP,您可以在此处按照我们的指南进行操作。

步骤 3. 在 Ubuntu 20.04 上安装 Teampass 密码管理器。

现在我们运行以下命令从 Git 存储库下载最新版本的 Teampass:

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

步骤 4. 配置 MariaDB。

默认情况下,MariaDB 未加固。 您可以使用 mysql_secure_installation 脚本。 您应该仔细阅读以下每个步骤,这些步骤将设置 root 密码、删除匿名用户、禁止远程 root 登录、删除测试数据库和访问安全 MariaDB:

mysql_secure_installation

像这样配置它:

- Set root password? [Y/n] y - 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 控制台并为 Teampass 创建一个数据库。 运行以下命令:

mysql -u root -p

这将提示您输入密码,因此输入您的 MariaDB 根密码并点击 Enter. 登录到数据库服务器后,您需要为 Teampass 安装创建数据库:

MariaDB [(none)]> create database teampass_db; MariaDB [(none)]> grant all privileges on teampass_db.* to [email protected] identified by "your-strong-password"; MariaDB [(none)]> flush privileges; MariaDB [(none)]> exit;

步骤 5. 配置 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>

Save 和 close 该文件然后启用 Apache 虚拟主机并重启 Apache 应用更改的服务:

sudo a2ensite teampass sudo a2enmod rewrite sudo systemctl restart apache2

第 6 步:使用 Let’s Encrypt 保护 TeamPass。

首先,您需要在您的服务器上安装 Certbot 客户端,以便为您的域下载并安装 Let’s Encrypt SSL:

sudo apt install python3-certbot-apache

然后,运行以下命令为您的网站下载并安装 Let’s Encrypt SSL:

certbot --apache -d teampass.your-domain.com

然后将提示您输入证书的电子邮件地址。 输入后,您必须同意 T&C 并决定是否要与电子前沿基金会共享您的电子邮件地址。

输出:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully enabled https://teampass.your-domain.com  You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=teampass.your-domain.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  IMPORTANT NOTES:  - Congratulations! Your certificate and chain have been saved at:    /etc/letsencrypt/live/teampass.your-domain.com/fullchain.pem    Your key file has been saved at:    /etc/letsencrypt/live/teampass.your-domain.com/privkey.pem    Your cert will expire on 2021-01-25. 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"  - 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

接下来,我们设置一个 cron 作业来自动更新 SSL 证书:

certbot renew --dry-run

您可以通过编辑以下文件来设置 cron 作业以在每天凌晨 12:00 自动更新 SSL 证书:

crontab -e

添加以下行:

00 12 * * *   root /usr/bin/certbot renew >/dev/null 2>&1

步骤 7. 访问 Teampass Web 界面。

成功安装后,打开您的 Web 浏览器并使用 URL 访问 Teampass Web 界面 https://teampass.your-domain.com. 您应该看到以下页面:

恭喜! 您已成功安装 Teampass。 感谢您使用本教程在 Ubuntu 20.04 LTS Focal Fossa 系统上安装 Teampass 密码管理器。 如需更多帮助或有用信息,我们建议您查看 Teampass 官方网站.