LoginSignup
4
15

More than 5 years have passed since last update.

パスワード管理ツール「Passbolt」を導入してみた

Last updated at Posted at 2017-07-31

passboltの導入で困惑した

上司「社内のアカウントの管理が社員によって権限を変更するのが面倒だからpassboltを導入してくれ」
僕「passboltですか?」
上司「サーバーかりてインストールするだけだから」
僕「わかりました」
日本語の資料ねーじゃん!!
・・・後日・・・
上司「前にインストールしたらエラーが大量に出ちゃったんだよね」
僕「・・・」

ということで英語のドキュメントを見ながらインストールをすることになった。

passboltとは

公式サイト

passboltとはCakePHPで作成されオープンソースのWEBベースのツール。passboltを使うことでチーム内で用いるパスワード情報をチーム全員で共有ではなく、特定のものだけ共有するといったことができるツール。

課題

  • 社員によって公開していいアカウント情報が異なる
  • 部署によっても異なる
  • アカウント情報はエクセル管理でサイボウズで公開していい社員ごとに分けて開示している
  • Googleスプレッドシートだとアカウント情報漏れのリスクが怖い

やりたいこと

  • 安全に楽をしたい

導入環境を準備

PHP >= 5.4, MySQL >= 5.0が前提条件でOSやDBに特に指定はないようなので以下でサーバーを設定した。

  • EC2
  • CentOS7
  • PHP7
  • MariaDB
  • Nginx

導入

  • 参考サイト

How to install passbolt on your own server.
Installing passbolt on Centos 7

手順

  1. Nginxインストール
  2. MariaDBインストール
  3. PHP & gnupgをインストール
  4. 秘密鍵を生成
  5. passboltの設定とインストール

1. Nginxインストール

  • 最初に /etc/yum.repos.d/nginx.repo を作成し以下を追記する。
[nginx]
name=nginx repo
# mainline : newest
baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
# stable : older, no new features
#baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
  • nginxをyumでインストールする。
yum update
yum install nginx

2. MariaDBインストール

  • yumでインストールする。
yum install mariadb-server
  • mariadbを起動する。
service mariadb start
  • お約束のコマンド。
mysql_secure_installation
  • mariadbにログインをする。mysql_secure_installation で設定したパスワードを入力してログインする。
mysql -u root -p
  • データベースを作成してログアウト。
create database passbolt;
exit;

3. PHP & gnupgをインストール

  • CentOS7用のWebTaticリポジトリを追加
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
  • yum clean all && yum update -y 実行後にPHPをインストールする
yum install php70w-fpm php70w-opcache php70w-gd php70w-mysql php70w-mcrypt php70w-cli php70w-pear php70w-devel

インストールしたパッケージの内容が知りたい方はこちら…

php70w-fpm is the package Nginx will rely on for understanding .php code
php70w-opcache is the package that gets the bytecode from .php files into the memory for faster access.
php70w-gd is required by passbolt, this includes the GD library.
php70w-mysql is required to connect to the MySQL/MariaDB database
php70w-mcrypt, is used for the mcrypt functions
php70w-cli is the PHP cli tool, its used for the installation off passbolt
php70w-pear is needed to install pecl, which is needed to install gnupg
php70w-devel is needed when we compile gnupg for PHP
yum install gpgme-devel gcc

を実行し、

pecl install gnupg

で gnupng をインストールする。

インストールが成功すると以下が表示される。

Build process completed successfully
Installing '/usr/lib64/php/modules/gnupg.so'
install ok: channel://pecl.php.net/gnupg-1.4.0
configuration option "php_ini" is not set to php.ini location
You should add "extension=gnupg.so" to php.ini
  • 上記はUbunto上のApacheのガイドラインになっている。CentOSのPHPモジュールの読み込み方法に合わせ、 /etc/php.d/ フォルダを作成し gnupg.ini を作成し以下を追記する。
# load the gnupg module for passbolt
extension=gnupg.so
  • php-fpmを再起動する。
service php-fpm restart
  • 起動確認をする php --info | grep 'gnupg support' を打ち込んで下の表示がされたら無事インストール完了。
gnupg support => enabled

4. 秘密鍵を生成

マシンのエントロピーが低いと gpg --gen-key でキーが生成されないことがある。

  • エントロピーを確認するコマンド
cat /proc/sys/kernel/random/entropy_avail
  • もし低いようだったら(もしくはキーが生成されないようだったら) rng-tools をインストールする
yum install rng-tools
  • 次にそれを/dev/urandomにバインド(?)する。
rngd -r /dev/urandom
  • ここまできてやっと gpg --gen-key でキーを生成する。
dumydumydumydumydumy
  • passhhraseは入力しないことそのまま[OK]を選択する。
-------------------------------------------------------
| Enter passphrase                                    |
|                                                     |
|                                                     |
| Passphrase ________________________________________ |
|                                                     |
|       <OK>                             <Cancel>     |
-------------------------------------------------------
  • [Take this one anyway]を選択する。
 ----------------------------------------------------------------------
 | Warning: You have entered an insecure passphrase.                  |
 | A passphrase should be at least 8 characters long.                 |
 |                                                                    |
 | <Take this one anyway>                      <Enter new passphrase> |
 ----------------------------------------------------------------------

何度かしつこく聞かれるがpassphraseは入力しないように選択をし続ける

  • [Yes, protection is not needed]を選択する。
-------------------------------------------------------------------------------------------------
| You have not entered a passphrase - this is in general a bad idea!                            |
| Please confirm that you do not want to have any protection on your key.                       |
|                                                                                               |
| <Yes, protection is not needed>                                    <Enter new passphrase>     |
-------------------------------------------------------------------------------------------------
  • もう一度入力を求めらえるが空のまま[ok]を選択するとキーが生成される。
-------------------------------------------------------
| Enter passphrase                                    |
|                                                     |
|                                                     |
| Passphrase ________________________________________ |
|                                                     |
|       <OK>                             <Cancel>     |
-------------------------------------------------------
  • Key fingerprint をひかえておく。
There is NO WARRANTY, to the extent permitted by law.

gpg: directory `/root/.gnupg' created
gpg: new configuration file `/root/.gnupg/gpg.conf' created
gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/root/.gnupg/secring.gpg' created
gpg: keyring `/root/.gnupg/pubring.gpg' created
Please select what kind of key you want:
   (1) RSA and RSA (default)
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
Your selection? 1
RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048)
Requested keysize is 2048 bits
Please specify how long the key should be valid.
         0 = key does not expire
      <n>  = key expires in n days
      <n>w = key expires in n weeks
      <n>m = key expires in n months
      <n>y = key expires in n years
Key is valid for? (0) 0
Key does not expire at all
Is this correct? (y/N) y

GnuPG needs to construct a user ID to identify your key.

Real name: 名前
Email address: メールアドレス
Comment: コメント
You selected this USER-ID:
    "名前 <メールアドレス>"

Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
You need a Passphrase to protect your secret key.

You don't want a passphrase - this is probably a *bad* idea!
I will do it anyway.  You can change your passphrase at any time,
using this program with the option "--edit-key".

We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key 70F6754E marked as ultimately trusted
public and secret key created and signed.

gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0  valid:   1  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 1u
pub   2048R/70F6754E 2017-07-31
      Key fingerprint = xxxx xxxx xxxx xxxx xxxx  xxxx xxxx xxxx xxxx xxxx
uid                  名前 <メールアドレス>
sub   2048R/E82D4DE0 2017-07-31
  • 作成されたキーをエクスポートする。
mkdir -p /opt/passbolt/
gpg --armor --export-secret-keys user@domain.ext > /opt/passbolt/serverkey.private.asc
gpg --armor --export user@domain.ext > /opt/passbolt/serverkey.asc

5. passboltの設定とインストール

  • passboltのソースを置くディレクトりそ作成し、passboltのソースを取得する。
cd /var/www/html/passbolt
git clone https://github.com/passbolt/passbolt.git
  • 権限の設定をする。
chmod +w -R /var/www/html/passbolt/app/tmp
chmod +w /var/www/html/passbolt/app/webroot/img/public
chown -R nginx.nginx /var/www/html/passbolt/
  • インストールに必要な各設定ファイルのコピーして作成する。
cp app/Config/core.php.default app/Config/core.php
cp app/Config/database.php.default app/Config/database.php
cp app/Config/app.php.default app/Config/app.php
  • app/Config/core.php の設定をする。 passbolt自体にはsaltとcipherSeedは必要ないが、CakePHPには必要な模様…
# salt can be any random string
Configure::write('Security.salt', '自分で生成した文字列');
# cipherSeed should be a random number
Configure::write('Security.cipherSeed', '自分で生成した数値列');
# https://subdomain.svennd.be
#  - your own obv
Configure::write('App.fullBaseUrl', 'http://{スラッシュなしの任意のドメイン}');
  • 次に app/Config/database.php の設定をする。
public $default = array(
  'datasource' => 'Database/Mysql',
  'persistent' => false,
  'host' => 'localhost',
  'login' => '設定したユーザー',
  'password' => '設定したパスワード',
  'database' => '2.MariaDBインストールの手順で作成したDB名(passbolt)'
);
  • 作成したキーにnginxユーザーがアクセスできるように権限を変更する。
cp -a /root/.gnupg/ /opt/passbolt/
chown -R nginx.nginx /opt/passbolt/.gnupg
chown -R nginx.nginx /opt/passbolt/*
  • 最後に app/Config/app.php の設定を行う。 gpg --list-keys --fingerprint で 生成したfingerprintを確認することができる。
$config = [
    'GPG' => [
        'env' => [
            'setenv' => true,
            'home' => '/opt/passbolt/.gnupg'
         ],
         'serverKey' => [
             'fingerprint' => '先ほど確認したfingerprintを**スペースをなくして**入力',
             'public'      => '/opt/passbolt/serverkey.asc',
             'private'     => '/opt/passbolt/serverkey.private.asc'

             // PHP Gnupg module currently does not support passphrase, please leave blank
             'passphrase' => ''
         ]
     ]
  • インストールする。
su -s /bin/bash -c "app/Console/cake install --no-admin" nginx
  • はい、エラーが発生します。
Error: syntax error, unexpected ''passphrase'' (T_CONSTANT_ENCAPSED_STRING), expecting ']'
#0 /var/www/html/passbolt/lib/Cake/Core/Configure.php(329): PhpReader->read('app')
#1 /var/www/html/passbolt/app/Config/bootstrap.php(26): Configure::load('app')
#2 /var/www/html/passbolt/lib/Cake/Core/Configure.php(98): include('/var/www/html/p...')
#3 /var/www/html/passbolt/lib/Cake/bootstrap.php(432): Configure::bootstrap(true)
#4 /var/www/html/passbolt/lib/Cake/Console/ShellDispatcher.php(145): require('/var/www/html/p...')
#5 /var/www/html/passbolt/lib/Cake/Console/ShellDispatcher.php(100): ShellDispatcher->_bootstrap()
#6 /var/www/html/passbolt/lib/Cake/Console/ShellDispatcher.php(54): ShellDispatcher->_initEnvironment()
#7 /var/www/html/passbolt/lib/Cake/Console/ShellDispatcher.php(65): ShellDispatcher->__construct(Array)
#8 /var/www/html/passbolt/app/Console/cake.php(47): ShellDispatcher::run(Array)
#9 {main}
  • app/Config/app.php が参考にしてたサイトとちょっと変わってしまっていたようです。passphraseの個所をコメントアウトしたらインストール成功しました。
$config = [
    'GPG' => [
        'env' => [
            'setenv' => true,
            'home' => '/opt/passbolt/.gnupg'
         ],
         'serverKey' => [
             'fingerprint' => '先ほど確認したfingerprintを**スペースをなくして**入力',
             'public'      => '/opt/passbolt/serverkey.asc',
             'private'     => '/opt/passbolt/serverkey.private.asc'

             // PHP Gnupg module currently does not support passphrase, please leave blank
             //'passphrase' => ''
         ]
     ]
  • コメントアウトをしたらもう一度 /bin/bash -c "app/Console/cake install --no-admin" nginx を入力する。うまくいくと下のような表示がされます。
---------------------------------------------------------------
     ____                  __          ____
    / __ \____  _____ ____/ /_  ____  / / /_
   / /_/ / __ `/ ___/ ___/ __ \/ __ \/ / __/
  / ____/ /_/ (__  |__  ) /_/ / /_/ / / /
 /_/    \__,_/____/____/_.___/\____/_/\__/

 Open source password manager for teams
---------------------------------------------------------------
 Install shell
---------------------------------------------------------------
 Avatar deleted!
Installing schema / database
---------------------------------------------------------------

Cake Schema Shell
---------------------------------------------------------------

The following table(s) will be dropped.
roles
users
authentication_tokens
profiles
email_queue
resources
secrets
groups
groups_users
gpgkeys
comments
permissions_types
permissions
controller_logs
user_agents
favorites
schema_migrations
Dropping table(s).
roles updated.
users updated.
authentication_tokens updated.
profiles updated.
email_queue updated.
resources updated.
secrets updated.
groups updated.
groups_users updated.
gpgkeys updated.
comments updated.
permissions_types updated.
permissions updated.
controller_logs updated.
user_agents updated.
favorites updated.
schema_migrations updated.

The following table(s) will be created.
roles
users
authentication_tokens
profiles
email_queue
resources
secrets
groups
groups_users
gpgkeys
comments
permissions_types
permissions
controller_logs
user_agents
favorites
schema_migrations
Creating table(s).
Table roles created
roles updated.
Table users created
users updated.
Table authentication_tokens created
authentication_tokens updated.
Table profiles created
profiles updated.
Table email_queue created
email_queue updated.
Table resources created
resources updated.
Table secrets created
secrets updated.
Table groups created
groups updated.
Table groups_users created
groups_users updated.
Table gpgkeys created
gpgkeys updated.
Table comments created
comments updated.
Table permissions_types created
permissions_types updated.
Table permissions created
permissions updated.
Table controller_logs created
controller_logs updated.
Table user_agents created
user_agents updated.
Table favorites created
favorites updated.
Table schema_migrations created
Execute specific schema PermissionsSchema (ok)
schema_migrations updated.
End create.
passbolt schema deployed

Cake Schema Shell
---------------------------------------------------------------

The following table(s) will be dropped.
cake_sessions
Dropping table(s).
cake_sessions updated.

The following table(s) will be created.
cake_sessions
Creating table(s).
cake_sessions updated.
End create.
passbolt session table deployed

Cake Schema Shell
---------------------------------------------------------------

The following table(s) will be dropped.
file_storage
Dropping table(s).
file_storage updated.

The following table(s) will be created.
file_storage
Creating table(s).
file_storage updated.
End create.
plugins schemas deployed

Installing data set:default
---------------------------------------------------------------
Data for model SchemaMigration inserted (11)
Data for model Role inserted (4)
Data for model User inserted (1)
Data for model Gpgkey inserted (0)
Data for model PermissionType inserted (3)
Data for model Profile inserted (1)
We need you to help make passbolt better by sending anonymous usage statistics. Ok?
(see: https://www.passbolt.com/privacy#statistics) (y/n)
[n] > y

 Datasource : default
 File :/var/www/html/passbolt/app/tmp/schema/default_default.sql
 Success: the database was saved on file!
---------------------------------------------------------------

 Passbolt installation success! Enjoy! ?

passphraseのコメントアウトがわからず時間がかかってしまいました…

続きはこちら続・パスワード管理ツール「Passbolt」を導入してみた

4
15
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
15