diff --git a/class/core/firewall_api.py b/class/core/firewall_api.py index 7ea605485..278e6739c 100755 --- a/class/core/firewall_api.py +++ b/class/core/firewall_api.py @@ -296,11 +296,17 @@ class firewall_api: conf = mw.readFile(file) - if status == '1': + pass_rep = "PasswordAuthentication\s+(\w*)\s*\n" + pass_status = re.search(pass_rep, conf) + if not pass_status: rep = "(#)?PasswordAuthentication\s+(\w*)\s*\n" conf = re.sub(rep, "PasswordAuthentication yes\n", conf) + + if status == '1': + rep = "PasswordAuthentication\s+(\w*)\s*\n" + conf = re.sub(rep, "PasswordAuthentication yes\n", conf) else: - rep = "(#)?PasswordAuthentication\s+(\w*)\s*\n" + rep = "PasswordAuthentication\s+(\w*)\s*\n" conf = re.sub(rep, "PasswordAuthentication no\n", conf) mw.writeFile(file, conf) mw.execShell("systemctl restart sshd.service")