From 26b7c255de3c9aa53b66c88a3a69e31f011f7dca Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Tue, 11 Jul 2023 15:10:20 +0900 Subject: [PATCH] Doc: Enhance SSH public key authentication setting section in "8.2. Pgpool-II + Watchdog Setup Example". --- doc.ja/src/sgml/example-cluster.sgml | 52 ++++++++++++++++++-- doc/src/sgml/example-cluster.sgml | 71 ++++++++++++++++++++++++---- 2 files changed, 111 insertions(+), 12 deletions(-) diff --git a/doc.ja/src/sgml/example-cluster.sgml b/doc.ja/src/sgml/example-cluster.sgml index d726327ef..3f3372fff 100644 --- a/doc.ja/src/sgml/example-cluster.sgml +++ b/doc.ja/src/sgml/example-cluster.sgml @@ -402,7 +402,17 @@ host replication all samenet scram-sha-256 - 自動フェイルオーバ、オンラインリカバリ機能を利用するには、Pgpool-II起動ユーザ(デフォルトではroot)とpostgresユーザ間、postgresユーザとpostgresユーザ間が双方向にパスワードなしでSSH接続できる状態になっている必要があります。全サーバで以下のコマンドを実行し、SSHの設定を行います。生成される鍵ファイル名はid_rsa_pgpoolとします。 + 自動フェイルオーバ、オンラインリカバリ機能を利用するには、すべてのPgpool-IIノード間でPgpool-IIの起動ユーザ(デフォルトはpostgresユーザ。Pgpool-II 4.0以前、デフォルトはrootユーザ)およびPostgreSQLの起動ユーザ(デフォルトはpostgresユーザ)として双方向にSSH公開鍵認証(パスワードなし)で接続できるように設定する必要があります。 + + + まず、全サーバでpostgresユーザのパスワードを設定します。 + + +[全サーバ]# passwd postgres + + + 全サーバで以下のコマンドを実行し、SSH公開鍵の登録を行います。 + この設定例では生成される鍵ファイル名はid_rsa_pgpoolとします。 [全サーバ]# mkdir ~/.ssh @@ -423,9 +433,45 @@ host replication all samenet scram-sha-256 [全サーバ]$ ssh-copy-id -i id_rsa_pgpool.pub postgres@server3 - 設定後、rootユーザ及びpostgresユーザからssh postgres@serverX -i ~/.ssh/id_rsa_pgpoolコマンドを実行し、パスワード入力せずログインできることを確認してください。 - ssh-copy-idの実行に失敗する場合は、postgres ユーザのパスワードを設定し、一時的にパスワード認証を有効化するなどしてください。 + 設定後、Pgpool-IIの起動ユーザでおよびPostgreSQLの起動ユーザでssh postgres@serverX -i ~/.ssh/id_rsa_pgpoolコマンドを実行し、パスワード入力せずログインできることを確認してください。 + + + + 公開鍵認証によるログインに失敗した場合には、以下を確認してください。 + + + + /etc/ssh/sshd_configで公開鍵認証が許可されていることを確認します。 + + + + +PubkeyAuthentication yes + + + + + SSHのパスワード認証を無効化している場合は、ssh-copy-idの実行に失敗するので、一時的に/etc/ssh/sshd_config内のPasswordAuthenticationをyesに変更するなどしてください。 + + + + +PasswordAuthentication yes + + + + + SELinuxを有効化している場合は、SSH公開鍵認証(パスワードなし)が失敗する可能性があるので、すべてのサーバで以下のコマンドを実行する必要があります。 + + + + +[全サーバ]# su - postgres +[全サーバ]$ restorecon -Rv ~/.ssh + + + diff --git a/doc/src/sgml/example-cluster.sgml b/doc/src/sgml/example-cluster.sgml index 87af178fe..034422de0 100644 --- a/doc/src/sgml/example-cluster.sgml +++ b/doc/src/sgml/example-cluster.sgml @@ -409,11 +409,23 @@ host replication all samenet scram-sha-256 To use the automated failover and online recovery of Pgpool-II, - the settings that allow passwordless SSH to all backend servers - between Pgpool-II execution user (default root user) - and postgres user and between postgres user - and postgres user are necessary. Execute the following command on all servers - to set up passwordless SSH. The generated key file name is id_rsa_pgpool. + it is requried to allow SSH public key authentication + (passwordless SSH login) to all backend servers + as Pgpool-II startup user + (default is postgres. Pgpool-II 4.0 or before, default is root) + and PostgreSQL startup user (default is postgres). + + + First, set postgres user's passwrod. + + +[all servers]# passwd postgres + + + Execute the following command on all servers + to set up passwordless SSH. + In this example, we assume that the generated key file name is + id_rsa_pgpool. [all servers]# mkdir ~/.ssh @@ -434,11 +446,52 @@ host replication all samenet scram-sha-256 [all servers]$ ssh-copy-id -i id_rsa_pgpool.pub postgres@server3 - After setting, use ssh postgres@serverX -i ~/.ssh/id_rsa_pgpool command to - make sure that you can log in without entering a password. If you fail - executing ssh-copy-id, set a password for postgres user - and temporarily allow password authentication for example. + After setting SSH, make sure that you can run + ssh postgres@serverX -i ~/.ssh/id_rsa_pgpool command + as Pgpool-II startup user and + PostgreSQL startup user to + log in without entering a password. + + + + If you failed to login using SSH public key authentication, please check the following: + + + + Ensure the public key authentication option PubkeyAuthentication are allowed in /etc/ssh/sshd_config: + + + + +PubkeyAuthentication yes + + + + + if the password authentication is disabled, you can fail to run + ssh-copy-id, temporarily add the following + configuration in /etc/ssh/sshd_config. + + + + +PasswordAuthentication yes + + + + + If SELinux is enabled, SSH public key authentication (passwordless SSH) may fail. + You need to run the following command on all servers. + + + + +[all servers]# su - postgres +[all servers]$ restorecon -Rv ~/.ssh + + + -- 2.39.5