在本页
- 先决条件
- 安装 Apache、MariaDB 和 PHP
- 为 sysPass 创建数据库
- 安装 sysPass
- 为 sysPass 配置 Apache 虚拟主机
- 访问 sysPass Web 界面
- 在 sysPass 上启用 Let's Encrypt SSL 支持
- 结论
sysPass 是一个用 PHP 编写的基于 Web 的密码管理应用程序。它安全、可靠,可在多用户环境中运行,适用于商业和个人用途。它使用双向加密和主密码将密码保存到数据库中。它提供了一个直观的 Web 界面,可帮助您设置 LDAP 认证、邮件、审计、备份、导入/导出等选项。
功能特性
- 免费且开源
- 组/配置文件访问控制
- 密码加密
- 文件存储与内联图片查看器
- OpenLDAP 和 Active Directory 集成
- 通过电子邮件提供通知
在本教程中,我将向您展示如何在 Debian 11 上安装 sysPass 密码管理应用程序,并使用免费的 Let's Encrypt SSL 证书对其进行保护。
先决条件
- 一台运行 Debian 11 的服务器。
- 一个指向您服务器 IP 的有效域名。
- 服务器上已配置 root 密码。
安装 Apache、MariaDB 和 PHP
sysPass 运行在 Web 服务器上,使用 MariaDB 作为数据库后端,并用 PHP 编写。因此您需要在服务器上安装 Apache Web 服务器、MariaDB 数据库服务器、PHP 以及其他 PHP 扩展。您可以使用以下命令安装所有这些组件:
apt-get install apache2 mariadb-server libapache2-mod-php php php-mysqli php-pdo php-pear php php-cgi php-cli php-common php-gd php-json php-readline php-curl php-intl php-ldap php-xml php-mbstring git -y
所有软件包安装完成后,编辑 php.ini 文件并进行一些更改:
nano /etc/php/7.4/apache2/php.ini
更改以下设置:
post_max_size = 100M upload_max_filesize = 100M max_execution_time = 7200 memory_limit = 512M date.timezone = Asia/Kolkata
完成后保存并关闭文件。接下来,重启 Apache 服务以应用配置更改:
systemctl restart apache2
为 sysPass 创建数据库
默认情况下,MariaDB 的安装并不安全。因此您需要先对其进行安全加固。您可以使用以下命令进行安全加固:
mysql_secure_installation
按照下面所示回答所有问题,以设置 MariaDB root 密码并加固安装:
Enter current password for root (enter for none): Switch to unix_socket authentication [Y/n] Y 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 root 密码。登录后,使用以下命令创建数据库和用户:
MariaDB [(none)]> create database syspassdb;
MariaDB [(none)]> grant all privileges on syspassdb.* to syspassuser@localhost identified by "password";
接下来,使用以下命令刷新权限并退出 MariaDB shell:
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit;
此时,您的 MariaDB 数据库和用户已为 sysPass 准备就绪。您现在可以继续下一步。
安装 sysPass
首先,您需要从 Git 仓库下载最新版本的 sysPass。您可以使用以下命令下载:
git clone https://github.com/nuxsmin/sysPass.git
下载完成后,将下载的目录移动到 Apache Web 根目录:
mv sysPass /var/www/html/syspass
接下来,使用以下命令为 syspass 目录设置适当的所有权:
chown -R www-data:www-data /var/www/html/syspass
接下来,为其他目录设置适当的权限:
chmod 750 /var/www/html/syspass/app/{config,backup}
接下来,您需要在系统上安装 Composer。
首先,使用以下命令创建 Composer 安装脚本:
nano /var/www/html/syspass/install-composer.sh
添加以下行:
#!/bin/sh
EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
ACTUAL_SIGNATURE="$(php -r "echo hash_file('sha384', 'composer-setup.php');")"
if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]
then
>&2 echo 'ERROR: Invalid installer signature'
rm composer-setup.php
exit 1
fi
php composer-setup.php --quiet
RESULT=$?
rm composer-setup.php
exit $RESULT
保存并关闭文件,然后使用以下命令运行 Composer 安装脚本:
cd /var/www/html/syspass/
sh install-composer.sh
Composer 安装完成后,运行以下命令安装所有必需的 PHP 依赖项:
php composer.phar install --no-dev
所有依赖项安装完成后,您可以继续下一步。
为 sysPass 配置 Apache 虚拟主机
接下来,您需要创建一个 Apache 虚拟主机配置文件,以便在网上托管 sysPass。您可以使用以下命令创建它:
nano /etc/apache2/sites-available/syspass.conf
添加以下行:
<VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "/var/www/html/syspass" ServerName syspass.example.com <Directory "/var/www/html/syspass/"> Options MultiViews FollowSymlinks AllowOverride All Order allow,deny Allow from all </Directory> TransferLog /var/log/apache2/syspass_access.log ErrorLog /var/log/apache2/syspass_error.log </VirtualHost>
完成后保存并关闭文件,然后使用以下命令激活 Apache 虚拟主机:
a2ensite syspass
接下来,重启 Apache 服务以应用更改:
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 Sat 2021-10-16 13:41:36 UTC; 4s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 17819 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 17824 (apache2)
Tasks: 6 (limit: 2341)
Memory: 14.7M
CPU: 76ms
CGroup: /system.slice/apache2.service
??17824 /usr/sbin/apache2 -k start
??17825 /usr/sbin/apache2 -k start
??17826 /usr/sbin/apache2 -k start
??17827 /usr/sbin/apache2 -k start
??17828 /usr/sbin/apache2 -k start
??17829 /usr/sbin/apache2 -k start
Oct 16 13:41:36 debian11 systemd[1]: Starting The Apache HTTP Server...
完成后,您可以继续下一步。
访问 sysPass Web 界面
此时,sysPass 已安装并托管在 Apache Web 服务器上。现在,打开您的 Web 浏览器,使用 URL http://syspass.example.com 访问 sysPass Web 界面。您将被重定向到以下页面:


提供您的管理员用户名、密码、主密码、数据库凭据,选择您的语言和托管模式,然后点击 INSTALL 按钮。安装完成后,您将被重定向到 sysPass 登录页面。

提供您的管理员用户名和密码,然后点击 > 按钮。您应该在以下页面看到 sysPass 仪表板:

在 sysPass 上启用 Let's Encrypt SSL 支持
使用 Let's Encrypt SSL 保护您的网站始终是一个好主意。首先,您需要安装 Certbot 客户端来安装和管理 SSL。默认情况下,Certbot 软件包包含在 Debian 11 的默认仓库中,因此您可以使用以下命令安装它:
apt-get install python3-certbot-apache -y
Certbot 安装完成后,运行以下命令以使用 Let's Encrypt SSL 保护您的网站:
certbot --apache -d syspass.example.com
系统会要求您提供电子邮件并接受服务条款,如下所示:
Saving debug log to /var/log/letsencrypt/letsencrypt.log Plugins selected: Authenticator standalone, Installer None 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 Plugins selected: Authenticator apache, Installer apache Obtaining a new certificate Performing the following challenges: http-01 challenge for syspass.example.com Enabled Apache rewrite module Waiting for verification... Cleaning up challenges Created an SSL vhost at /etc/apache2/sites-available/syspass-le-ssl.conf Enabled Apache socache_shmcb module Enabled Apache ssl module Deploying Certificate to VirtualHost /etc/apache2/sites-available/syspass-le-ssl.conf Enabling available site: /etc/apache2/sites-available/syspass-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 并按 Enter,为您的网站安装 Let's Encrypt SSL:
Enabled Apache rewrite module Redirecting vhost in /etc/apache2/sites-enabled/syspass.conf to ssl vhost in /etc/apache2/sites-available/syspass-le-ssl.conf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Congratulations! You have successfully enabled https://syspass.example.com You should test your configuration at: https://www.ssllabs.com/ssltest/analyze.html?d=syspass.example.com - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at: /etc/letsencrypt/live/syspass.example.com/fullchain.pem Your key file has been saved at: /etc/letsencrypt/live/syspass.example.com/privkey.pem Your cert will expire on 2021-07-20. 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
结论
恭喜!您已在 Debian 11 上使用 Apache 成功安装了 sysPass 密码管理器。您现在可以创建其他账户、添加用户、设置访问权限,并将其部署到生产环境中。