Last active
May 24, 2021 15:38
-
-
Save mikeslattery/6b9d5532450a1b1c72e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
:: Setup an ssd daemon/server on a Windows server box on the internal network. | |
set ROOT=C:\cygwin | |
set PACKAGES=openssh,nc,curl,tmux | |
set SITE=http://cygwin.mirror.constant.com | |
set BASH=%ROOT%\bin\bash --login -c | |
set PACKAGEDIR=%ROOT%\packages | |
echo INSTALL CYGWIN... | |
net stop sshd >nul 2>nul | |
if not exist %ROOT%\setup.exe ( | |
echo Downloading setup.exe... | |
mkdir %ROOT% 2> nul | |
powershell -noprofile -executionpolicy bypass -command "(new-object net.webclient).DownloadFile('https://cygwin.com/setup-x86_64.exe', '%ROOT%\setup.exe')" | |
if errorlevel 1 goto error | |
) | |
mkdir %PACKAGEDIR% 2>nul | |
echo Installing packages... | |
%ROOT%\setup.exe -q -P %PACKAGES% -l %PACKAGEDIR% -R %ROOT% -s %SITE% | |
echo @%ROOT%\bin\bash --login -i>%ROOT%\Cygwin.bat | |
if errorlevel 1 goto error | |
echo Installing apt-cyg... | |
%BASH% "curl -kLO 'https://rawgit.com/transcode-open/apt-cyg/master/apt-cyg'" | |
%BASH% "install apt-cyg /bin && rm apt-cyg" | |
if errorlevel 1 goto error | |
echo ENABLE SSHD... | |
netsh advfirewall firewall add rule name="ssd Daemon" dir=in action=allow remoteip=localsubnet protocol=TCP localport=22 | |
if errorlevel 1 goto error | |
%BASH% "set -x; ssh-host-config --yes --name sshd --pwd $(openssl rand -base64 21)" | |
if errorlevel 1 goto error | |
%BASH% "/bin/mkpasswd -d %USERDOMAIN% -c > /etc/passwd" | |
if errorlevel 1 goto error | |
net start sshd | |
@echo Done. | |
goto end | |
:error | |
@echo. | |
@echo An error occurred. | |
exit /b 1 | |
:end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This no longer works and I don't plan to fix. Windows 10 comes with a nice built-in ssh server.
If anybody supplies me with a patch, I'll happily apply it (but won't test it).