diff --git a/packages/openssh_srv.xml b/packages/openssh_srv.xml new file mode 100755 index 0000000000000000000000000000000000000000..10bf3c2a3f599a09efcd6656434e5b866471235a --- /dev/null +++ b/packages/openssh_srv.xml @@ -0,0 +1,73 @@ +<?xml version="1.0" encoding="UTF-8"?> +<packages:packages xmlns:packages="http://www.wpkg.org/packages"> + +<!-- http://www.kpym.com/2/kpym/index.htm + + Installs a SSH server onto Windows pcs. If it's the first time this program has been installed on this pc then a copy of the + SSH keys are made to a directory on the win-info share. If this program has been installed before then the SSH keys that were + saved are copied back, saves any warning people may get if the keys have changed. + + Download the manual zip package instead of using the Windows Feature - https://github.com/PowerShell/Win32-OpenSSH/releases + +--> + + <package id="openssh_srv" name="Openssh" revision="%version%" reboot="false" priority="51"> + <variable name="version" value="8.1.0.0" /> + <variable name="svc_name" value="sshd" /> + <variable name="svc_name_agent" value="ssh-agent" /> + + <check type="file" condition="versionequalto" path="%ProgramFiles%\openssh\sshd.exe" value="%version%"/> + + <install cmd='%COMSPEC% /c mkdir "%ProgramFiles%\OpenSSH"' /> + <install cmd='%COMSPEC% /c xcopy /sechky "%WPKGSOFTWARE%\openssh\%version%\*" "%ProgramFiles%\OpenSSH\"' /> + <install cmd='%COMSPEC% /c powershell.exe -ExecutionPolicy Bypass -File "%ProgramFiles%\OpenSSH\install-sshd.ps1"' /> + <install cmd='%COMSPEC% /c netsh AdvFirewall firewall delete rule name="%svc_name%"' > + <exit code="1" /> + </install> + <install cmd='%COMSPEC% /c netsh advfirewall firewall add rule name=%svc_name% dir=in action=allow protocol=TCP localport=22' /> + <install cmd='%COMSPEC% /c net stop "%svc_name%"'> <!-- net waits for the service to start/stop, sc does not --> + <exit code="any" /> + </install> + <install cmd='%COMSPEC% /c sc config "%svc_name%" start= delayed-auto' /> + <install cmd='%COMSPEC% /c net start "%svc_name%" & net stop "%svc_name%"' /> <!-- needs to run before we can copy old ssh key files back --> + <!-- if existing ssh keys are on \win-info then copy them back to local machine --> + <install cmd='%COMSPEC% /c xcopy /sechky "%WPKGWININFO%\locks\%COMPUTERNAME%\s*" "%Programdata%\ssh\"'> + <condition> + <check type="file" condition="exists" path="%WPKGWININFO%\locks\%COMPUTERNAME%\" /> + </condition> + </install> + <install cmd='%COMSPEC% /c net start "%svc_name%"' /> + <!--<install cmd='%COMSPEC% /c %WPKGSOFTWARE%\wpkg\tools\sleep 5' /> allow the service to start so it can create all of the files before copying them to \win-info --> + <!-- if there are no ssh key files on \win-info then start the sshd service to create the files and copy them to \win-info --> + <install cmd='%COMSPEC% /c xcopy /sechky "%Programdata%\ssh\*" "%WPKGWININFO%\locks\%COMPUTERNAME%\"'> + <condition> + <check type="logical" condition="not"> + <check type="file" condition="exists" path="%WPKGWININFO%\locks\%COMPUTERNAME%\" /> + </check> + </condition> + </install> + + <upgrade include='remove' /> + <upgrade include='install' /> + + <remove cmd='%COMSPEC% /c net stop "%svc_name%"' > + <exit code="any" /> + </remove> + <remove cmd='%COMSPEC% /c net stop "%svc_name_agent%"' > + <exit code="any" /> + </remove> + <remove cmd='%COMSPEC% /c rmdir /s /q "%ProgramFiles%\OpenSSH"' /> + <remove cmd='%COMSPEC% /c netsh AdvFirewall firewall delete rule name="%svc_name%"' > + <exit code="1" /> + </remove> + <remove cmd='%COMSPEC% /c sc delete "%svc_name%"' > + <exit code="any" /> + </remove> + <remove cmd='%COMSPEC% /c sc delete "%svc_name_agent%"' > + <exit code="any" /> + </remove> + <remove cmd='%COMSPEC% /c del /q %programdata%\ssh\s*' /> + + </package> + +</packages:packages>