Always set PermitRootLogin for sshd_config

it was only being set if the setting existed
This commit is contained in:
Lance Edgar 2018-03-11 20:34:39 -05:00
parent 38b99cd817
commit 4af428db78

View file

@ -71,11 +71,15 @@ def configure(allow_root=False):
Configure the OpenSSH service
"""
path = '/etc/ssh/sshd_config'
value = 'without-password' if allow_root else 'no'
sed(path, r'^PermitRootLogin\s+.*', 'PermitRootLogin {}'.format(value), use_sudo=True)
entry = 'PermitRootLogin {}'.format('without-password' if allow_root else 'no')
sed(path, r'^PermitRootLogin\s+.*', entry, use_sudo=True)
append(path, entry, use_sudo=True)
entry = 'PasswordAuthentication no'
sed(path, r'^PasswordAuthentication\s+.*', entry, use_sudo=True)
append(path, entry, use_sudo=True)
restart()