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: