|
|
|
@ -1,8 +1,22 @@ |
|
|
|
|
# -*- coding: utf-8 -*- |
|
|
|
|
from setuphelpers import * |
|
|
|
|
import requests,json |
|
|
|
|
from jinja2 import Environment, FileSystemLoader |
|
|
|
|
|
|
|
|
|
uninstallkey = [] |
|
|
|
|
variables = { |
|
|
|
|
'ssh_password_auth': False, |
|
|
|
|
'ssh_append_ciphers': True, |
|
|
|
|
'ssh_ciphers': [ 'aes256-cbc', 'aes192-cbc', 'aes128-cbc' ] |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
# Read local variables file if available |
|
|
|
|
if isfile(makepath(programfiles32,'wapt','private','symetric.txt')) and isfile(makepath(programfiles32,'wapt','private','variables.txt')): |
|
|
|
|
print('Reading local encrypted variables file') |
|
|
|
|
from cryptography.fernet import Fernet |
|
|
|
|
import yaml |
|
|
|
|
f = Fernet(open(makepath(programfiles32,'wapt','private','symetric.txt'),'r').read()) |
|
|
|
|
variables.update(yaml.safe_load(f.decrypt(open(makepath(programfiles32,'wapt','private','variables.txt'),'r').read()))) |
|
|
|
|
|
|
|
|
|
def install(): |
|
|
|
|
print('Installing OpenSSH') |
|
|
|
@ -31,7 +45,22 @@ def install(): |
|
|
|
|
run_notfatal(r'netsh advfirewall firewall del rule name="OpenSSH Server"') |
|
|
|
|
run(r'netsh advfirewall firewall add rule name="OpenSSH Server" dir=in action=allow protocol=TCP localport=22 enable=yes') |
|
|
|
|
|
|
|
|
|
print(' Starting the service') |
|
|
|
|
print(' Deploy sshd_config') |
|
|
|
|
jinja2 = Environment( |
|
|
|
|
loader=FileSystemLoader('.'), |
|
|
|
|
trim_blocks=True |
|
|
|
|
) |
|
|
|
|
open(makepath(os.getenv('ProgramData',r'C:\ProgramData'),'ssh','sshd_config'),'w').write( |
|
|
|
|
jinja2.get_template('sshd_config.j2').render( |
|
|
|
|
ssh_ciphers = ('+' if variables['ssh_append_ciphers'] == True else '') + ','.join(variables['ssh_ciphers']), |
|
|
|
|
ssh_password_auth = variables['ssh_password_auth'] |
|
|
|
|
) |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
print(' (Re)starting the service') |
|
|
|
|
if service_is_running('sshd'): |
|
|
|
|
service_restart('sshd') |
|
|
|
|
else: |
|
|
|
|
service_start('sshd') |
|
|
|
|
|
|
|
|
|
print(r' Enabling sshd service on boot') |
|
|
|
|