在 Ubuntu 22.04 上安装带有 Free Lets Encrypt SSL 的 sysPass 密码管理器
本教程适用于这些操作系统版本
- Ubuntu 22.04(Jammy Jellyfish)
- Ubuntu 20.04(Focal Fossa)
在此页
- 先决条件
- 安装 Apache、MariaDB 和 PHP
- 为 sysPass 配置 MariaDB
- 安装系统通行证
- 为 sysPass 配置 Apache
- 访问 sysPass 管理界面
- 在 sysPass 上安装 Lets Encrypt SSL
- 结论
sysPass 是一个免费的、开源的、基于 PHP 的密码管理工具,用于将您的密码保存在一个安全的位置。它基于 Web,安全可靠,专为多用户环境而设计。它带有一个用户友好的 Web 界面,可帮助用户配置不同的选项,如 LDAP 身份验证、邮件、审计、备份、导入/导出等。sysPass 可以通过 Web 应用程序、移动应用程序和浏览器扩展安装。
在本文中,我们将向您展示如何在 Ubuntu 22.04 上安装 sysPass 密码管理器。
先决条件
- 一台运行 Ubuntu 22.04 的服务器。
- 用您的服务器 IP 指向的有效域名。
- 在服务器上配置了根密码。
安装 Apache、MariaDB 和 PHP
在开始之前,您需要为您的服务器安装 Apache Web 服务器、MariaDB 数据库服务器、PHP 和其他 PHP 扩展。首先,使用以下命令安装 Apache 和 MariaDB 服务器:
apt-get install apache2 mariadb-server -y
默认情况下,Ubuntu 22.04 附带 PHP 8.1 版本,但 sysPass 不支持 PHP 8.1 版本。因此,您需要在服务器上安装带有其他扩展的 PHP 7.4 版本。
首先,使用以下命令安装所有必需的依赖项:
apt install software-properties-common ca-certificates lsb-release apt-transport-https
接下来,使用以下命令添加 PHP 存储库:
add-apt-repository ppa:ondrej/php
添加 PHP 存储库后,运行以下命令以安装具有所有必需扩展的 PHP 7.4:
apt install libapache2-mod-php7.4 php7.4 php7.4-mysqli php7.4-pdo php7.4 php7.4-cgi php7.4-cli php7.4-common php7.4-gd php7.4-json php7.4-readline php7.4-curl php7.4-intl php7.4-ldap php7.4-xml php7.4-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 = UTC
完成后保存并关闭文件。接下来,重新启动 Apache 服务以应用配置更改:
systemctl restart apache2
为 sysPass 配置 MariaDB
默认情况下,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
下载sysPass后,将下载的目录移动到Apache网站根目录:
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 虚拟主机配置文件以在 Web 上托管 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 prese>
Active: active (running) since Sun 2022-07-24 04:27:17 UTC; 6s ago
Docs: https://httpd.apache.org/docs/2.4/
Process: 62773 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/S>
Main PID: 62777 (apache2)
Tasks: 6 (limit: 2242)
Memory: 14.3M
CPU: 109ms
CGroup: /system.slice/apache2.service
??62777 /usr/sbin/apache2 -k start
??62778 /usr/sbin/apache2 -k start
??62779 /usr/sbin/apache2 -k start
??62780 /usr/sbin/apache2 -k start
??62781 /usr/sbin/apache2 -k start
??62782 /usr/sbin/apache2 -k start
Jul 24 04:27:17 ubuntu systemd[1]: Starting The Apache HTTP Server...
完成后,您可以继续下一步。
访问 sysPass 管理界面
现在,打开您的 Web 浏览器并使用 URL http://syspass.example.com 访问 sysPass 管理界面。您将被重定向到以下页面:


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

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

在 sysPass 上安装 Lets Encrypt SSL
使用 Lets Encrypt SSL 保护您的网站始终是个好主意。首先,您需要安装 Certbot 客户端来安装和管理 SSL。默认情况下,Certbot 包包含在 Ubuntu 22.04 默认存储库中,因此您可以使用以下命令安装它:
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 2022-10-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
结论
恭喜!您已经在 Ubuntu 22.04 上成功安装了带有 Apache 和 Lets Encrypt SSL 的 sysPass 密码管理器。您现在可以探索 sysPass 密码管理器并开始将其部署到您的生产环境中。