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