Skip to content

Commit 8516835

Browse files
EvilOlaftabrisnet
andauthored
don't fail distro agnostic sshd adjustments when config is not found (#8729)
* don't fail ssh distro agnostic when openssh is not used * addressing rabbit nit-pick reasonable * fix wording Co-authored-by: tabrisnet <96966042+tabrisnet@users.noreply.github.com> --------- Co-authored-by: tabrisnet <96966042+tabrisnet@users.noreply.github.com>
1 parent a6f0159 commit 8516835

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

lib/functions/rootfs/distro-agnostic.sh

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -487,11 +487,13 @@ function install_distribution_agnostic() {
487487
echo "nameserver $NAMESERVER" > "${SDCARD}"/etc/resolvconf/resolv.conf.d/head
488488
fi
489489

490-
# permit root login via SSH for the first boot
491-
sed -i 's/#\?PermitRootLogin .*/PermitRootLogin yes/' "${SDCARD}"/etc/ssh/sshd_config
492-
493-
# enable PubkeyAuthentication
494-
sed -i 's/#\?PubkeyAuthentication .*/PubkeyAuthentication yes/' "${SDCARD}"/etc/ssh/sshd_config
490+
# don't fail if OpenSSH is missing, e.g. if dropbear is installed instead
491+
if [[ -f "${SDCARD}"/etc/ssh/sshd_config ]]; then
492+
# permit root login via SSH for the first boot
493+
sed -i 's/#\?PermitRootLogin .*/PermitRootLogin yes/' "${SDCARD}"/etc/ssh/sshd_config
494+
# enable PubkeyAuthentication
495+
sed -i 's/#\?PubkeyAuthentication .*/PubkeyAuthentication yes/' "${SDCARD}"/etc/ssh/sshd_config
496+
fi
495497

496498
# avahi daemon defaults if exists
497499
[[ -f "${SDCARD}"/usr/share/doc/avahi-daemon/examples/sftp-ssh.service ]] &&

0 commit comments

Comments
 (0)