From 511f5194dcf12a64fc8a6c2791edc9c6cda2d926 Mon Sep 17 00:00:00 2001 From: Florence Blanc-Renaud Date: Fri, 19 Jun 2020 10:43:56 +0200 Subject: [PATCH] client install: fix broken sshd config If ipa client was installed with openssh-server >= 8.2, the configuration parameters for sshd were put in /etc/ssh/sshd_config instead of in a snippet in /etc/ssh/sshd_config.d. Upgrade to this new ipa version fixes the sshd conf by moving the params to the snippet. Related: https://pagure.io/freeipa/issue/8304 Reviewed-By: Alexander Bokovoy --- freeipa.spec.in | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/freeipa.spec.in b/freeipa.spec.in index d65bfe185..43e1e95ec 100755 --- a/freeipa.spec.in +++ b/freeipa.spec.in @@ -1089,7 +1089,7 @@ fi %endif -%triggerin client -- openssh-server +%triggerin client -- openssh-server < 8.2 # Has the client been configured? restore=0 test -f '/var/lib/ipa-client/sysrestore/sysrestore.index' && restore=$(wc -l '/var/lib/ipa-client/sysrestore/sysrestore.index' | awk '{print $1}') @@ -1125,6 +1125,26 @@ if [ -f '/etc/ssh/sshd_config' -a $restore -ge 2 ]; then fi +%triggerin client -- openssh-server >= 8.2 +# Has the client been configured? +restore=0 +test -f '/var/lib/ipa-client/sysrestore/sysrestore.index' && restore=$(wc -l '/var/lib/ipa-client/sysrestore/sysrestore.index' | awk '{print $1}') + +if [ -f '/etc/ssh/sshd_config' -a $restore -ge 2 ]; then + # If the snippet already exists, skip + if [ ! -f '/etc/ssh/sshd_config.d/04-ipa.conf' ]; then + # Take the values from /etc/ssh/sshd_config and put them in 04-ipa.conf + grep -E '^(PubkeyAuthentication|KerberosAuthentication|GSSAPIAuthentication|UsePAM|ChallengeResponseAuthentication|AuthorizedKeysCommand|AuthorizedKeysCommandUser)' /etc/ssh/sshd_config 2>/dev/null > /etc/ssh/sshd_config.d/04-ipa.conf + # Remove the values from sshd_conf + sed -ri ' + /^(PubkeyAuthentication|KerberosAuthentication|GSSAPIAuthentication|UsePAM|ChallengeResponseAuthentication|AuthorizedKeysCommand|AuthorizedKeysCommandUser)[ \t]/ d + ' /etc/ssh/sshd_config + + /bin/systemctl condrestart sshd.service 2>&1 || : + fi +fi + + %if ! %{ONLY_CLIENT} %files server