From 2945663087a01c58773d3969cf6da2ddb7aeaaea Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Wed, 28 Feb 2024 09:03:24 -0500 Subject: [PATCH] jjb: Enable the use of .ssh/authorized_keys2 when building images Change-Id: If4e760db7562c197056ba1996576688eea74e838 Signed-off-by: Kienan Stewart --- pipelines/images/imagebuild.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pipelines/images/imagebuild.sh b/pipelines/images/imagebuild.sh index 45632c0..befc9bf 100644 --- a/pipelines/images/imagebuild.sh +++ b/pipelines/images/imagebuild.sh @@ -173,6 +173,10 @@ CLEANUP+=( "rm -f ${HOME}/.ssh/id_rsa" ) lxc file push ~/.ssh/id_rsa.pub "ci:${INSTANCE_NAME}/root/.ssh/authorized_keys2" +# Some distros, eg. Rocky Linux, don't enable the use of authorized_keys2 +# by default +lxc exec "ci:${INSTANCE_NAME}" -- bash -c 'if test -f /etc/redhat-release ; then sed -i "s#^AuthorizedKeysFile.*#AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2#" /etc/ssh/sshd_config ; systemctl restart sshd ; fi' + # Confirm working SSH connection if ! ssh "${INSTANCE_IP}" hostname ; then -- 2.34.1