|
|
|
@ -8,25 +8,27 @@ def install(): |
|
|
|
|
print('Installing OpenSSH') |
|
|
|
|
mkdirs(makepath(programfiles,'OpenSSH')) |
|
|
|
|
print(' Stoping the service') |
|
|
|
|
run_notfatal(r'sc stop sshd') |
|
|
|
|
killalltasks('sshd.exe') |
|
|
|
|
if service_installed('sshd') and service_is_running('sshd'): |
|
|
|
|
service_stop('sshd') |
|
|
|
|
killalltasks('sshd.exe') |
|
|
|
|
print(' Extract OpenSSH archive') |
|
|
|
|
unzip('OpenSSH-Win%s.zip' % '64' if iswin64() else '32',makepath(programfiles,'OpenSSH')) |
|
|
|
|
run('"%s" e -y -o"%s" OpenSSH-Win%s.zip' % (makepath(programfiles,'7-Zip','7z.exe'),makepath(programfiles,'OpenSSH'),'64' if iswin64() else '32')) |
|
|
|
|
print(' Installing the service') |
|
|
|
|
run(r'powershell.exe -ExecutionPolicy Bypass -File "%s\install-sshd.ps1"' % makepath(programfiles,'OpenSSH')) |
|
|
|
|
print(' Opening port 22 in the firewall') |
|
|
|
|
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') |
|
|
|
|
run(r'sc start sshd', accept_returncodes=[0,1056]) |
|
|
|
|
service_start('sshd') |
|
|
|
|
print(r' Enabling sshd service on boot') |
|
|
|
|
run('sc config sshd start= auto') |
|
|
|
|
|
|
|
|
|
def uninstall(): |
|
|
|
|
print('Removing OpenSSH') |
|
|
|
|
print(' Stoping the service') |
|
|
|
|
run_notfatal('sc stop sshd') |
|
|
|
|
killalltasks('ssh.exe') |
|
|
|
|
if service_is_running('sshd'): |
|
|
|
|
service_stop('sshd') |
|
|
|
|
killalltasks('sshd.exe') |
|
|
|
|
print(' Uninstalling the service') |
|
|
|
|
run(r'powershell.exe -ExecutionPolicy Bypass -File "%s\uninstall-sshd.ps1"' % makepath(programfiles,'OpenSSH')) |
|
|
|
|
print(' Removing files') |
|
|
|
|