From 77e1f435a1d121a4b3100593efa4f59499f5ed23 Mon Sep 17 00:00:00 2001 From: stegben Date: Thu, 14 May 2020 17:05:27 +0800 Subject: [PATCH 1/2] add test case for ssh connection under restart pgslave --- tests/ssh-connect/run.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/ssh-connect/run.sh b/tests/ssh-connect/run.sh index 8ded8022..891b2ab6 100755 --- a/tests/ssh-connect/run.sh +++ b/tests/ssh-connect/run.sh @@ -10,4 +10,11 @@ CHECKED_TEXT= if [[ "1" != `docker-compose exec pgmaster bash -c 'gosu postgres ssh -o LogLevel=QUIET -t pgslave1 "cat /tmp/ssh_check"' | grep SSH_CHECK | wc -l | tr -d ' '` ]]; then exit 1 -fi \ No newline at end of file +fi + +docker-compose restart pgslave +sleep 5 + +if [[ "1" != `docker-compose exec -T pgmaster bash -c 'gosu postgres ssh -o LogLevel=QUIET -t pgslave "cat /tmp/ssh_check"' | grep SSH_CHECK | wc -l | tr -d ' '` ]]; then + exit 1 +fi From 556ada75839cfcd9902ea0128092cd4f3b504f4f Mon Sep 17 00:00:00 2001 From: stegben Date: Thu, 14 May 2020 17:07:16 +0800 Subject: [PATCH 2/2] fix messed-up authroized_keys file while restarting --- src/ssh/sshd_start | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ssh/sshd_start b/src/ssh/sshd_start index 78d48a9e..54f83490 100755 --- a/src/ssh/sshd_start +++ b/src/ssh/sshd_start @@ -21,6 +21,7 @@ if [[ "$SSH_ENABLE" == "1" ]]; then sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd echo "export VISIBLE=now" >> /etc/profile + echo -e "\n" >> $PG_HOME/.ssh/authorized_keys # ensure new line cat $PG_HOME/.ssh/id_rsa.pub >> $PG_HOME/.ssh/authorized_keys echo '>>> STARTING SSH SERVER...'