From 6372c8dc9b550f3d7cb66198c5f9aba4db0f58f1 Mon Sep 17 00:00:00 2001 From: Anthony Date: Thu, 27 Feb 2025 00:38:19 +0800 Subject: [PATCH] Fixed PasswordAuthentication --- manifest.jps | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/manifest.jps b/manifest.jps index cb29495..4701643 100644 --- a/manifest.jps +++ b/manifest.jps @@ -75,9 +75,15 @@ onInstall: wget https://deploy-proxy.mightybox.io/addons/add-sftp-user/raw/branch/main/add-sftp.sh -O /home/jelastic/add-sftp-user-addon/add-sftp.sh chmod +x /home/jelastic/add-sftp-user-addon/*.sh - cmd[cp]: - user: root - commands: - - echo -e "\nMatch User user*\nPasswordAuthentication yes" >> /etc/ssh/sshd_config + user: root + commands: |- + if grep -qE "^Match User user[0-9]*$" /etc/ssh/sshd_config; then + sed -i '/^Match User user[0-9]*/!b;n;c\ PasswordAuthentication yes' /etc/ssh/sshd_config + else + echo -e "\n# Added by SFTP addon\nMatch User user*\n\tPasswordAuthentication yes" >> /etc/ssh/sshd_config + fi + awk '!seen[$0]++' /etc/ssh/sshd_config > /etc/ssh/sshd_config.tmp && mv /etc/ssh/sshd_config.tmp /etc/ssh/sshd_config + systemctl restart sshd - cmd[cp]: user: root commands: