Another fix for secure

This commit is contained in:
VirtuBox
2019-09-23 12:35:11 +02:00
parent 050365ace6
commit 7f11e24044

View File

@@ -148,20 +148,16 @@ class WOSecureController(CementBaseController):
@expose(hide=True)
def secure_ssh(self):
"""Harden ssh security"""
pargs = self.app.pargs
if pargs.user_input:
current_ssh_port = pargs.user_input
else:
if os.path.isfile('/etc/ssh/sshd_config'):
for line in open('/etc/ssh/sshd_config', encoding='utf-8'):
if 'Port' in line:
ssh_line = line.strip()
if os.path.isfile('/etc/ssh/sshd_config'):
for line in open('/etc/ssh/sshd_config', encoding='utf-8'):
if 'Port' in line:
ssh_line = line.strip()
break
else:
port = (ssh_line).split(' ')
current_ssh_port = port[1]
else:
Log.error(self, "SSH config file not found")
port = (ssh_line).split(' ')
current_ssh_port = port[1]
else:
Log.error(self, "SSH config file not found")
if not current_ssh_port:
current_ssh_port = '22'
data = dict(sshport=current_ssh_port, allowpass='no')