如何在CentOS 7上安裝Passbolt自託管密碼管理器
Passbolt是一個免費的開源密碼管理器,適用於團隊。 它允許團隊成員安全地儲存和共享憑據/密碼。 Passbolt是使用PHP建立的,可以在LEMP堆疊下執行或作為docker容器執行。
必要條件
- CentOS 7
- Root許可權
我們將要做什麼?
- 安裝依賴項
- 安裝和配置MariaDB資料庫
- 安裝Nginx和PHP-FPM
- 生成SSL Letsencrypt
- 配置Nginx和PHP-FPM
- 下載Passbolt並生成OpenPGP金鑰
- 安裝Passbolt
- Passbolt安裝後
- 其他安全伺服器設定
第1步 - 安裝依賴項
我們將為本指南做的第一件事是安裝Passbolt安裝所需的所有包依賴項,包括安裝EPEL和Remi PHP儲存庫,php composer,gcc等。
新增EPEL儲存庫。
sudo yum -y install yum-utils epel-release
新增並啟用Remi PHP儲存庫。
sudo yum -y install 'http://rpms.remirepo.net/enterprise/remi-release-7.rpm'
sudo yum-config-manager --enable 'remi-php72'
現在使用下面的yum命令安裝包依賴項composer,git gcc等。
等待所有軟體包安裝。
第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密碼。
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
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
如果安裝完成,請啟動PHP-FPM服務並在系統引導時每次啟動它。
sudo systemctl start php-fpm
sudo systemctl enable php-fpm
已安裝Nginx Web伺服器和PHP-FPM。
第4步 - 生成SSL Letsencrypt
在系統上安裝certbot工具。
sudo yum -y install certbot
現在停止nginx服務。
sudo systemctl stop nginx
執行下面的certbot命令。
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
貼上配置如下。
儲存並退出。
測試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 [email protected] > /var/www/passbolt/config/gpg/serverkey_private.asc
gpg --armor --export [email protected] > /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
在“應用”部分,用你自己的域名改變域名。
在“資料來源”配置中,鍵入詳細資訊資料庫資訊。
在資料庫配置下,新增新的'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' => ['[email protected]_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
現在開啟一個新選項卡並貼上給位址列的“註冊”連結。 我的是:
選中底部的框,然後點選“下一步”按鈕。 現在,系統會要求您為使用者建立新金鑰。
單擊“下一步”按鈕。
設定“密碼短語”,輸入您的強密碼。
設定密碼
單擊“下一步”按鈕。 按“下載”按鈕備份您的金鑰,然後再次單擊“下一步”。
下載備份金鑰
對於安全令牌,請將其保留為預設值,然後單擊“下一步”。
設定安全令牌
您將被重定向到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