如何在 Debian 11 上安装 sysPass 密码管理器
在此页
- 先决条件
- 安装 Apache、MariaDB 和 PHP
- 为 sysPass 创建数据库
- 安装系统通行证
- 为 sysPass 配置 Apache 虚拟主机
- 访问 sysPass 网络用户界面
- 在 sysPass 上启用 Lets Encrypt SSL 支持
- 结论
sysPass 是一个用 PHP 编写的基于 Web 的密码管理应用程序。它安全、可靠,可在多用户环境中运行,供企业和个人使用。它使用带有主密码的双向加密将密码保存到数据库中。它提供了一个直观的 Web 用户界面,可帮助您设置 LDAP 身份验证、邮件、审计、备份、导入/导出等选项。
特征
- 免费和开源
- 组/个人资料访问控制
- 密码加密
- 带有内联图像查看器的文件存储
- OpenLDAP 和 Active Directory 集成
- 通过电子邮件提供通知
在本教程中,我将向您展示如何在 Debian 11 上安装 sysPass 密码管理器应用程序并使用免费的 Lets Encrypt SSL 证书对其进行保护。
先决条件
- 运行 Debian 11 的服务器。
- 用您的服务器 IP 指向的有效域名。
- 在服务器上配置了根密码。
安装 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 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 虚拟主机配置文件以在 Internet 上托管 sysPass。您可以使用以下命令创建它:
nano /etc/apache2/sites-available/syspass.conf
添加以下行:
<VirtualHost *:80>
ServerAdmin
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 浏览器并使用 URL http://syspass.example.com 访问 sysPass Web 界面。您将被重定向到以下页面:


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

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

在 sysPass 上启用 Lets Encrypt SSL 支持
使用 Lets Encrypt SSL 保护您的网站始终是个好主意。首先,您需要安装 Certbot 客户端来安装和管理 SSL。默认情况下,Certbot 包包含在 Debian 11 默认存储库中,因此您可以使用以下命令安装它:
apt-get install python3-certbot-apache -y
安装 Certbot 后,运行以下命令以使用 Lets 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):
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
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 键为您的网站安装 Lets 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 密码管理器。您现在可以创建一个不同的帐户、添加用户、访问权限并将其部署到您的生产环境中。