Skip to content

Commit 175c1dc

Browse files
author
Kristan Kenney
committed
Fix detection of SFTP configuration
Improved logic for detecting variations in sshd_config. Thanks to @Lupul for this fix.
1 parent 2b2f68c commit 175c1dc

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

install/hst-install-debian.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -892,10 +892,10 @@ rm -f /usr/sbin/policy-rc.d
892892
sed -i "s/rdAuthentication no/rdAuthentication yes/g" /etc/ssh/sshd_config
893893

894894
# Enable SFTP subsystem for SSH
895-
sftp_subsys_enabled=$(grep "#Subsystem sftp-server" /etc/ssh/sshd_config)
895+
sftp_subsys_enabled=$(grep -iE "^#?.*subsystem.+(sftp )?sftp-server" /etc/ssh/sshd_config)
896896
if [ ! -z "$sftp_subsys_enabled" ]; then
897897
echo "(*) Updating SFTP subsystem configuration..."
898-
sed -i "s/#Subsystem sftp-server/Subsystem sftp internal-sftp/gI" /etc/ssh/sshd_config
898+
sed -i -E "s/^#?.*Subsystem.+(sftp )?sftp-server/Subsystem sftp internal-sftp/g" /etc/ssh/sshd_config
899899
fi
900900

901901
# Disable SSH suffix broadcast

install/hst-install-ubuntu.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -866,10 +866,10 @@ rm -f /usr/sbin/policy-rc.d
866866
sed -i "s/rdAuthentication no/rdAuthentication yes/g" /etc/ssh/sshd_config
867867

868868
# Enable SFTP subsystem for SSH
869-
sftp_subsys_enabled=$(grep "#Subsystem sftp-server" /etc/ssh/sshd_config)
869+
sftp_subsys_enabled=$(grep -iE "^#?.*subsystem.+(sftp )?sftp-server" /etc/ssh/sshd_config)
870870
if [ ! -z "$sftp_subsys_enabled" ]; then
871871
echo "(*) Updating SFTP subsystem configuration..."
872-
sed -i "s/#Subsystem sftp-server/Subsystem sftp internal-sftp/gI" /etc/ssh/sshd_config
872+
sed -i -E "s/^#?.*Subsystem.+(sftp )?sftp-server/Subsystem sftp internal-sftp/g" /etc/ssh/sshd_config
873873
fi
874874

875875
# Disable SSH suffix broadcast

install/upgrade/0.10.0-190430.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,10 @@ fi
345345
$HESTIA/bin/v-add-sys-sftp-jail
346346

347347
# Enable SFTP subsystem for SSH
348-
sftp_subsys_enabled=$(cat /etc/ssh/sshd_config | grep "#Subsystem sftp-server")
348+
sftp_subsys_enabled=$(grep -iE "^#?.*subsystem.+(sftp )?sftp-server" /etc/ssh/sshd_config)
349349
if [ ! -z "$sftp_subsys_enabled" ]; then
350350
echo "(*) Updating SFTP subsystem configuration..."
351-
sed -i "s/#Subsystem sftp-server/Subsystem sftp internal-sftp/gI" /etc/ssh/sshd_config
351+
sed -i -E "s/^#?.*Subsystem.+(sftp )?sftp-server/Subsystem sftp internal-sftp/g" /etc/ssh/sshd_config
352352
service ssh restart
353353
fi
354354

0 commit comments

Comments
 (0)