Well I think Cyg­win is a great tool, BUT the instal­la­tion is really.. ermm.. let’s say ugly. That’s why we cre­ated a small zip file (2mb), which con­tains all the files you need to run a Cyg­win SSH server. We cre­ated a small script, which will set up your sshd.

Be sure to edit the _install.cmd file first and enter the cor­rect path (where to install the ssh server) and enter a pass­word for the SSHD ser­vice which matches the pass­word rules given on your sys­tem. Also note that this is NOT a high secu­rity instal­la­tion, check the secu­rity set­tings your­self. And you need to edit the passwd file after the instal­la­tion, to enter a cor­rect shell (use usershell.cmd as an exam­ple) — bash is not included (and bash is in the passwd file as default)!

down­load neophob’s cyg­win sshd package

Here is the install script::## the install direc­tory
set INSTALL-DIR=c:ssh

:## the install direc­tory, yes the same as above, except you need to use dou­ble back­slash (\), its for the .reg file we gen­er­ate
set REGINSTALL-DIR=c:\ssh

:## the pass­word of the sshd ser­vice
set SSHDUSER-PASSWORD=pa$$word

:## used for instal­la­tion, nor­mally you dont need to change that!
set REGFILE=%INSTALL-DIR%cygmount.reg

@echo.
@echo ———————————————————————–
@echo CAUTION! READ THIS FIRST (READ IT REALLY!) — dont blame me if you dont!
@echo ———————————————————————–
@echo.
@echo this script will install cyg­win ssh server (or sshd). this script will:
@echo  –cre­ate a local user called sshd_server
@echo  –cre­ate a ser­vice called sshd­NEO (dis­play name: CYGWIN sshd NEOPHOB.COM)
@echo.
@echo be sure that:
@echo  –you are logged in as a admin­is­tra­tor
@echo  –you didnt all­ready use cyg­win — else your instal­la­tion will be unus­able!
@echo  –this machine is not a domain con­troller — this will not work
@echo                                             (dc’s dont have local user’s)
@echo  –this is just a quick hack, check the secu­rity set­ting on your own!
@echo  –you edited or reviewed the first lines of this script (install direc­to­ries)
@echo  –you know what you’re doing.
@echo.
@echo Com­ments or hints to: admin@neophob.com — http://www.neophob.com
@echo.
@echo.
@echo Press Ctrl + C to abort now.
@echo.
pause
echo REGEDIT4 > %REGFILE%
echo [HKEY_LOCAL_MACHINESOFTWARECygnus Solu­tion­sCyg­win­mounts v2]» %REGFILE%
echo “cyg­drive prefix”=”/cygdrive”» %REGFILE%
echo “cyg­drive flags”=dword:00000022» %REGFILE%
echo [HKEY_LOCAL_MACHINESOFTWARECygnus Solu­tion­sCyg­win­mounts v2/]» %REGFILE%
echo “native”=”%REGINSTALL-DIR%”» %REGFILE%
echo “flags”=dword:0000000a» %REGFILE%

regedit %REGFILE%

echo # gen­er­ate ssh keys…
ssh-keygen –t rsa1 –f .etcssh_host_key –N ”
ssh-keygen –t rsa –f .etcssh_host_rsa_key –N ”
ssh-keygen –t dsa –f .etcssh_host_dsa_key –N ”

echo # add local user sshd_server…
net user sshd_server %SSHDUSER-PASSWORD% /add /fullname:“sshd server account” /EXPIRES:NEVER /yes

echo # add sshd_server user to admin group…
net local­group Admin­is­tra­tors sshd_server /add

echo # gen­er­ate passwd file from local users…
mkpasswd.exe –l » .etcpasswd

echo # grant sshd_server account user rights…
editrights –a SeAssign­Pri­ma­ry­To­ken­Priv­i­lege –u sshd_server
editrights –a SeCre­ate­To­ken­Priv­i­lege –u sshd_server
editrights –a SeDeny­In­ter­ac­tiveL­o­gonRight –u sshd_server
editrights –a SeDenyNet­work­L­o­gonRight –u sshd_server
editrights –a SeDenyRe­moteIn­ter­ac­tiveL­o­gonRight –u sshd_server
editrights –a SeIn­crease­Quo­taPriv­i­lege –u sshd_server
editrights –a SeSer­viceL­o­gonRight –u sshd_server

echo # install ser­vice sshd­NEO
cygrun­srv –I sshd­NEO –d “CYGWIN sshd NEOPHOB.COM” –p /sshd –a –D –u sshd_server –w %SSHDUSER-PASSWORD% –e “CYGWIN=ntsec”

echo # fix some secu­rity set­tings…
chown sshd_server /etc/ssh*
chown sshd_server /var/log/empty
chown sshd_server /var/log/ssh*.log
chmod 700 /etc/ssh*
chmod 770 /var/log/*

echo # in the file /etc/passwd, change the line from:
echo “# Administrator:..<skipped>..:/home/Administrator:/bin/bash“
echo # to:
echo “# Administrator:..<skipped>..:/home/Administrator:/usershell.cmd”

notepad %INSTALL-DIR%etcpasswd