2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-11-19 08:52:20 +00:00

Serve installtodisk syncfiles with the sshd of the image

After image2disk, installimage stopped the sshd of the image and moved
port 22 to the initramfs sshd, chrooted into the install target, by
sending that sshd HUP. The el9 initramfs only starts its sshd with
debugssh, and on EL 9.8 it cannot start at all without sshd-session, so
normally nothing listened on port 22. The syncfiles push of post.sh then
failed with connection refused while the node still reported completed.

Restart the sshd of the image instead, chrooted into the install target.
It is always present and matches the OpenSSH helpers of the image, so
this also works for images packed or captured before the initramfs fix.
Wait for the old sshd to exit first, so the new one can bind port 22.
This commit is contained in:
Markus Hilger
2026-11-09 20:26:06 +01:00
parent 81f375f6da
commit e23873888f
@@ -25,8 +25,6 @@ else
done
fi
cd /sysroot/run
[ -f /run/sshd.pid ] &&
cp /run/sshd.pid /tmp/dbgssh.pid
chmod 0600 /sysroot/etc/ssh/ssh*key
chroot /sysroot/ bash -c "/usr/sbin/sshd"
chroot /sysroot/ bash -c "source /etc/confluent/functions; run_remote_python getinstalldisk"
@@ -49,11 +47,14 @@ if [ -f /sysroot/etc/lvm/devices/system.devices ]; then
fi
chroot /sysroot /usr/lib/systemd/systemd-udevd --daemon
chroot /sysroot bash -c "source /etc/confluent/functions; run_remote_python image2disk.py"
echo "Port 22" >> /etc/ssh/sshd_config
echo 'Match LocalPort 22' >> /etc/ssh/sshd_config
echo ' ChrootDirectory /sysroot/run/imginst/targ' >> /etc/ssh/sshd_config
kill $(cat /sysroot/var/run/sshd.pid)
[ -f /tmp/dbgssh.pid ] && kill -HUP $(cat /tmp/dbgssh.pid)
sshdpid=$(cat /sysroot/var/run/sshd.pid)
kill $sshdpid
# wait for the old sshd to release port 22
for i in {1..50}; do kill -0 $sshdpid 2> /dev/null || break; sleep 0.1; done
# Serve the install target on port 22 for the syncfiles push of post.sh. Use
# the sshd of the image: the initramfs sshd only runs with debugssh and may
# lack helpers of the image's OpenSSH version, like sshd-session
chroot /sysroot /usr/sbin/sshd -p 22 -o ChrootDirectory=/run/imginst/targ
cp /sysroot/etc/pki/ca-trust/source/anchors/* /sysroot/run/imginst/targ/etc/pki/ca-trust/source/anchors/
chroot /sysroot/run/imginst/targ update-ca-trust