diff --git a/install.sh b/install.sh index b9f6fbd..698566d 100644 --- a/install.sh +++ b/install.sh @@ -99,6 +99,27 @@ cp "$SSHD_CONFIG" "$BACKUP" cp "$SCRIPT_DIR/ssh" "$SSHD_CONFIG" chmod 600 "$SSHD_CONFIG" +# The template carries the Debian path for sftp-server. sshd -t does not check +# that the binary exists, so on other distributions SFTP would silently break. +SFTP_SERVER="" +for candidate in \ + /usr/lib/openssh/sftp-server \ + /usr/libexec/openssh/sftp-server \ + /usr/lib/ssh/sftp-server \ + /usr/libexec/sftp-server +do + if [[ -x "$candidate" ]]; then + SFTP_SERVER="$candidate" + break + fi +done +if [[ -n "$SFTP_SERVER" ]]; then + sed -i "s|^Subsystem sftp .*|Subsystem sftp $SFTP_SERVER|" "$SSHD_CONFIG" + echo "Using sftp-server: $SFTP_SERVER" +else + echo "WARNING: no sftp-server binary found; leaving the Subsystem line unchanged." +fi + # Validate SSH config (silent) if ! sshd -t 2>/dev/null; then echo "ERROR: SSH configuration is invalid!" diff --git a/ssh b/ssh index d1abcad..a79bc05 100644 --- a/ssh +++ b/ssh @@ -28,3 +28,8 @@ AcceptEnv LANG LC_* Subsystem sftp /usr/lib/openssh/sftp-server UsePAM yes Banner /etc/bannerssh + +# Kept last on purpose. OpenSSH uses the first value it obtains for a keyword, +# so everything above still wins over any drop-in; this only lets the Match +# blocks that menu.sh writes to sshd_config.d (per-user banners) take effect. +Include /etc/ssh/sshd_config.d/*.conf