阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

如何在CentOS 7上安装Passbolt自托管密码管理器

280次阅读
没有评论

共计 8104 个字符,预计需要花费 21 分钟才能阅读完成。

Passbolt 是一个免费的开源密码管理器,适用于团队。它允许团队成员安全地存储和共享凭据 / 密码。Passbolt 是使用 PHP 创建的,可以在 LEMP 堆栈下运行或作为 docker 容器运行。

在本教程中,我们将向您展示逐步安装并在 CentOS 7 服务器上配置开源密码管理器“Passbolt”。Passbolt 是一个用 PHP 开发的 Web 应用程序,我们将在 LEMP(Linux,Nginx,MySQL/MariaDB 和 PHP-FPM)下运行它。

必要条件

  • CentOS 7
  • Root 权限

我们将要做什么?

  1. 安装依赖项
  2. 安装和配置 MariaDB 数据库
  3. 安装 Nginx 和 PHP-FPM
  4. 生成 SSL Letsencrypt
  5. 配置 Nginx 和 PHP-FPM
  6. 下载 Passbolt 并生成 OpenPGP 密钥
  7. 安装 Passbolt
  8. Passbolt 安装后
  9. 其他安全服务器设置

第 1 步 – 安装依赖项

我们将为本指南做的第一件事是安装 Passbolt 安装所需的所有包依赖项,包括安装 EPEL 和 Remi PHP 存储库,php composer,gcc 等。

添加 EPEL 存储库。

sudo yum -y install yum-utils epel-release

如何在 CentOS 7 上安装 Passbolt 自托管密码管理器

添加并启用 Remi PHP 存储库。

sudo yum -y install ‘http://rpms.remirepo.net/enterprise/remi-release-7.rpm’

如何在 CentOS 7 上安装 Passbolt 自托管密码管理器

sudo yum-config-manager –enable ‘remi-php72’

如何在 CentOS 7 上安装 Passbolt 自托管密码管理器

现在使用下面的 yum 命令安装包依赖项 composer,git gcc 等。

sudo yum -y install unzip wget composer policycoreutils-Python git gcc

如何在 CentOS 7 上安装 Passbolt 自托管密码管理器

等待所有软件包安装。

第 2 步 – 安装和配置 MySQL / MariaDB

在此步骤中,我们将安装 MariaDB 数据库,然后为 Passbolt 安装创建新的数据库和用户。

使用下面的 yum 命令安装 MariaDB 服务器。

sudo yum -y install mariadb-server

安装完成后,启动 MariaDB 服务并使其在系统引导时每次启动。

sudo systemctl start mariadb
sudo systemctl enable mariadb

现在我们需要为 MariaDB 配置“root”密码。运行下面的 ’mysql_secure_installation’ 命令。

mysql_secure_installation

输入新的 root 密码。

并且已配置 MariaDB root 密码。

如何在 CentOS 7 上安装 Passbolt 自托管密码管理器

Remove anonymous users? [Y/n]  这里生产环境建议输入 y

Disallow root login remotely? [Y/n] 远程登陆

Remove test database and access to it? [Y/n]  删除测试数据库并访问它?[Y/ N]

Reload privilege tables now? [Y/n]  Y

All done!  If you’ve completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

接下来,使用“root”用户登录 MySQL shell。

mysql -u root -p

使用密码 ’password-linuxidc’ 创建一个名为 ’linuxidccom’ 的新数据库和用户,在下面运行 MySQL 查询。

create database passbolt;
grant all on passbolt.* to ‘linuxidccom’@’localhost’ identified by ‘password-linuxidc’;
flush privileges;
quit;

如何在 CentOS 7 上安装 Passbolt 自托管密码管理器

MariaDB 服务器已安装在 CentOS 7 服务器上,并且已创建用于“Passbolt”安装的数据库。

第 3 步 – 安装 Nginx 和 PHP-FPM

安装 MariaDB 服务器后,我们将使用 Remi 存储库从 EPEL 存储库和 PHP-FPM 软件包安装 Nginx。

安装 Nginx Web 服务器。

sudo yum -y install nginx

安装完成后,启动 Nginx 服务并使其在系统引导时每次启动。

sudo systemctl start nginx
sudo systemctl enable nginx

现在使用下面的 yum 命令安装 PHP-FPM 以及所需的所有扩展。

sudo yum -y install php-fpm php-intl php-gd php-mysql php-mcrypt php-pear php-devel php-mbstring php-fpm gpgme-devel

如何在 CentOS 7 上安装 Passbolt 自托管密码管理器

如果安装完成,请启动 PHP-FPM 服务并在系统引导时每次启动它。

sudo systemctl start php-fpm
sudo systemctl enable php-fpm

如何在 CentOS 7 上安装 Passbolt 自托管密码管理器

已安装 Nginx Web 服务器和 PHP-FPM。

第 4 步 – 生成 SSL Letsencrypt

在系统上安装 certbot 工具。

sudo yum -y install certbot

现在停止 nginx 服务。

sudo systemctl stop nginx

并为 passbolt 域名 ’linux.linuxidc.com’ 生成 SSL Letsencrypt。

运行下面的 certbot 命令。

sudo certbot certonly –standalone –agree-tos –no-eff-email –email linuxidc@linuxidc.com -d linux.linuxidc.com

certbot 工具将运行临时 Web 服务器进行验证。

完成后,您将在 ’/etc/letsencrypt/live/’ 目录中获取证书。

第 5 步 – 配置 Nginx 和 PHP-FPM

在此步骤中,我们将通过为 Passbolt 创建新的虚拟主机配置来配置 Nginx Web 服务器,并配置 PHP-FPM 并安装 PHP GnuPG 支持。

配置 PHP-FPM

转到 ’/etc/php-fpm.d’ 目录并使用 vim 编辑器编辑默认池配置 ’www.conf’。

cd /etc/php-fpm.d/
sudo vim www.conf

将默认用户和组更改为“nginx”用户。

user = nginx
group = nginx

将端口侦听 PHP-FPM 更改为 sock 文件,如下所示。

listen = /var/run/php-fpm/php-fpm.sock

取消注释下面的这些行,并将 sock 文件的 listen.owner 和 listen.group 更改为 ’nginx’。

listen.owner = nginx
listen.group = nginx
listen.mode = 0660

Save and exit.

现在我们需要更改 PHP 会话目录的所有者并安装 PHP GnuPG 扩展支持。

更改 php 会话目录的权限。

sudo chgrp nginx /var/lib/php/session

使用 pecl 命令安装 PHP GnuPG 扩展并激活它。

sudo pecl install gnupg
echo “extension=gnupg.so” > /etc/php.d/gnupg.ini

配置 Nginx 和 PHP-FPM

已安装 PHP GnuPG 扩展。

配置 Nginx 虚拟主机

转到 ’/etc/nginx/conf.d’ 目录并创建一个新的虚拟主机文件 ’passbolt.conf’。

cd /etc/nginx/conf.d/
sudo vim passbolt.conf

粘贴配置如下。

server {
  listen 443;
  server_name linux.linuxidc.com;
  ssl on;
  ssl_certificate    /etc/letsencrypt/live/linux.linuxidc.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/linux.linuxidc.com/privkey.pem;
  ssl_protocols TLSv1.2;
  ssl_prefer_server_ciphers on;
  ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS;
  ssl_session_tickets off;
  root /var/www/passbolt;
 
  location / {
    try_files $uri $uri/ /index.php?$args;
    index index.php;
  }
 
  location ~ \.php$ {
    fastcgi_index          index.php;
    fastcgi_pass            unix:/var/run/php-fpm/php-fpm.sock;
    fastcgi_split_path_info ^(.+\.php)(.+)$;
    include                fastcgi_params;
    fastcgi_param          SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_param          SERVER_NAME $http_host;
  }
     
  location ~* \.(jpe?g|woff|woff2|ttf|gif|png|bmp|ico|css|js|json|pdf|zip|htm|html|docx?|xlsx?|pptx?|txt|wav|swf|svg|avi|mp\d)$ {
    access_log off;
    log_not_found off;
    try_files $uri /webroot/$uri /index.php?$args;
  }
}

保存并退出。

测试 nginx 配置并确保没有错误。

sudo nginx -t

现在重启 Nginx 和 PHP-FPM 服务。

sudo systemctl restart nginx
sudo systemctl restart php-fpm

配置 Nginx 虚拟主机

Nginx Web 服务器和 PHP-FPM 的配置已成功完成。

第 6 步 – 下载 Passbolt 并生成 OpenPGP 密钥

在此步骤中,我们将下载 passbolt Web 应用程序并生成将用于 Passbolt API 的新 OpenPGP 密钥。

转到 ’/var/www’ 目录并克隆 passbolt Web 应用程序。

cd /var/www/
git clone https://github.com/passbolt/passbolt_api.git passbolt/

下载 Passbolt 并生成 OpenPGP 密钥

现在安装 ’hasged’ 包并启动服务。

sudo yum -y install haveged
sudo systemctl start haveged

使用下面的 gpg 命令生成新的 OpenPGP 密钥。

gpg –gen-key

输入您的详细信息,例如电子邮件,到期日等。

注意:

  • PHP GnuPG 扩展不支持 OpenPGP 密钥密码,因此让密码保持空白。

完成后,检查所有可用密钥并记下密钥的“指纹”。

gpg –list-keys –fingerprint

列出 gpg 密钥

现在将公钥和私钥导出到 ’/var/www/passbolt’ 目录。

gpg –armor –export-secret-keys hakase@hakase.io > /var/www/passbolt/config/gpg/serverkey_private.asc
gpg –armor –export hakase@hakase.io > /var/www/passbolt/config/gpg/serverkey.asc

并更改 ’/var/www/passbolt’ 目录的所有密钥权限和所有者。

sudo chmod 640 /var/www/passbolt/config/gpg/serverkey*
sudo chown -R  nginx:nginx /var/www/passbolt

已知的 gpg 键

已下载 Passbolt Web 应用程序,并已创建 OpenPGP 密钥。

第 7 步 – 安装 Passbolt

在安装 ’Passbolt’ 的所有依赖项之前,我们需要为 nginx 用户初始化 gpg 密钥的密钥环。

运行以下命令。

sudo su -s /bin/bash -c “gpg –list-keys” nginx

现在登录 ’nginx’ 用户并转到 ’/var/www/passbolt’ 目录。

su -s /bin/bash nginx
cd /var/www/passbolt/

安装 Passbolt

使用下面的 composer 命令安装 PassboltInstall 所有 passbolt 依赖项。

composer install –no-dev

Composer install

完成后,复制应用程序的默认配置文件并使用 vim 进行编辑。

cp config/passbolt.default.php config/passbolt.php

vim config/passbolt.php

在“应用”部分,用你自己的域名改变域名。

    ‘App’ => [
        // A base URL to use for absolute links.
        // The url where the passbolt instance will be reachable to your end users.
        // This information is need to render images in emails for example
        ‘fullBaseUrl’ => ‘https://linux.linuxidc.com’,
    ],

在“数据源”配置中,键入详细信息数据库信息。

    // Database configuration.
    ‘Datasources’ => [
        ‘default’ => [
            ‘host’ => ‘localhost’,
            //’port’ => ‘non_standard_port_number’,
            ‘username’ => ‘linuxidccom’,
            ‘password’ => ‘password-linuxidc’,
            ‘database’ => ‘linuxidccom’,
        ],
    ],

在数据库配置下,添加新的 ’ssl’ 配置以强制所有连接到安全 https。

    ‘ssl’ => [
        ‘force’ => true,
    ],

对于 SMTP 邮件配置,请使用您的详细信息更改所有内容。

    // Email configuration.
    ‘EmailTransport’ => [
        ‘default’ => [
            ‘host’ => ‘localhost’,
            ‘port’ => 25,
            ‘username’ => ‘user’,
            ‘password’ => ‘secret’,
            // Is this a secure connection? true if yes, null if no.
            ‘tls’ => null,
            //’timeout’ => 30,
            //’client’ => null,
            //’url’ => null,
        ],
    ],
    ‘Email’ => [
        ‘default’ => [
            // Defines the default name and email of the sender of the emails.
            ‘from’ => [‘passbolt@your_organization.com’ => ‘Passbolt’],
            //’charset’ => ‘utf-8’,
            //’headerCharset’ => ‘utf-8’,
        ],
    ],

最后,粘贴 OpenPGP 密钥的“指纹”并取消注释那些公共和私有配置行。

            ‘serverKey’ => [
                // Server private key fingerprint.
                ‘fingerprint’ => ’63BA4EBB65126A6BE334075DD210E985E2ED02E5′,
                ‘public’ => CONFIG . ‘gpg’ . DS . ‘serverkey.asc’,
                ‘private’ => CONFIG . ‘gpg’ . DS . ‘serverkey_private.asc’,
            ],

保存并退出。

Passbolt 配置文件

现在使用以下命令安装 ’Passbolt’。

./bin/cake passbolt install

系统将要求您创建新的管理员用户和密码 – 输入您的详细信息。

最后,您将获得“注册”链接,将其写在您的笔记上。

第 8 步 – Passbolt 安装后

打开 Web 浏览器并安装 Web 浏览器的“Passbolt”扩展。

以下是 Chrome 浏览器的 passbolt 扩展程序链接。 安装扩展。

https://chrome.google.com/webstore/detail/passbolt-extension

现在打开一个新选项卡并粘贴给地址栏的“注册”链接。我的是:

https://linux.linuxidc.com/setup/install/b830ec28-1cc5-6f5f-95f8-9be56acrfefa/103991n4-3971-4bb8-886c-856ac0f8c76f

选中底部的框,然后点击“下一步”按钮。现在,系统会要求您为用户创建新密钥。

单击“下一步”按钮。

设置“密码短语”,输入您的强密码。

设置密码

单击“下一步”按钮。按“下载”按钮备份您的密钥,然后再次单击“下一步”。

下载备份密钥

对于安全令牌,请将其保留为默认值,然后单击“下一步”。

设置安全令牌

您将被重定向到 Passbolt 登录页面。

Passbolt 登录页面

输入您的“密码短语”,然后点击“登录”。您将看到 Passbolt 用户仪表板。

欢迎来到 Passbolt

CentOS 7 上的 Passbolt 开源密码管理器安装已成功完成。

步骤 9 – 其他安全服务器设置

 – 设置 Firewalld

在服务器上打开新的 HTTP,HTTPS 和 SMTP 端口。

sudo firewall-cmd –add-service=http –permanent
sudo firewall-cmd –add-service=https –permanent
sudo firewall-cmd –add-service=smtp –permanent

现在重新加载 firewalld 配置。

sudo firewall-cmd –reload

 – 设置 Selinux 许可

“Passbolt”webroot 目录的权限。

sudo semanage fcontext -a -t httpd_sys_content_t ‘/var/www(/.*)?’
sudo semanage fcontext -a -t httpd_sys_rw_content_t ‘/var/www/passbolt/tmp(/.*)?’
sudo semanage fcontext -a -t httpd_sys_rw_content_t ‘/var/www/passbolt/logs(/.*)?’
sudo restorecon -Rv /var/www

Nginx gnupg 密钥环目录的权限。

sudo semanage fcontext -a -t httpd_sys_rw_content_t ‘/var/lib/nginx/.gnupg(/.*)?’
sudo restorecon -Rv /var/lib/nginx/.gnupg

参考:https://help.passbolt.com/hosting/install

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-21发表,共计8104字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中