From df945dd71be79e88a0d884c4365695054a18c8f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Hertzog?= Date: Tue, 17 Nov 2020 16:29:30 +0100 Subject: [PATCH] Don't tweak the SSH config if persistence is enabled And also ensure we run the initial configuration only once so that the user can override our initial changes. Fixes #22 --- .../usr/lib/live/config/0031-kali-user-setup | 8 ++++++++ .../usr/lib/live/config/1165-fix-openssh-server | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/kali-config/common/includes.chroot/usr/lib/live/config/0031-kali-user-setup b/kali-config/common/includes.chroot/usr/lib/live/config/0031-kali-user-setup index 6bd1ed2..82aa59a 100755 --- a/kali-config/common/includes.chroot/usr/lib/live/config/0031-kali-user-setup +++ b/kali-config/common/includes.chroot/usr/lib/live/config/0031-kali-user-setup @@ -19,6 +19,11 @@ configure_kaboxer() { adduser kali kaboxer } +# Avoid configuring multiple times in case persistence is enabled +if [ -e /var/lib/live/config/kali-user-setup ]; then + exit 0 +fi + # Set "kali" as password for the user kali usermod -p 'AqLUsDitNnTsw' kali @@ -27,3 +32,6 @@ configure_zsh # Add kali user to the kaboxer group configure_kaboxer + +# Remember that this script has been run +touch /var/lib/live/config/kali-user-setup diff --git a/kali-config/common/includes.chroot/usr/lib/live/config/1165-fix-openssh-server b/kali-config/common/includes.chroot/usr/lib/live/config/1165-fix-openssh-server index 30b9ac8..730d84d 100755 --- a/kali-config/common/includes.chroot/usr/lib/live/config/1165-fix-openssh-server +++ b/kali-config/common/includes.chroot/usr/lib/live/config/1165-fix-openssh-server @@ -1,4 +1,10 @@ #!/bin/sh +if grep -qw persistence /proc/cmdline; then + # With persistence enabled, don't modify the configuration, let the + # user be in charge... + exit 0 +fi + # Allow PasswordAuthentification in sshd config sed -i -e 's|#\?\(PasswordAuthentication\) no|\1 yes|' /etc/ssh/sshd_config