So you read the topic of this and think to yourself, “there are versions out there where all this is already done,” but by going with this route you will never learn anything other than how to use Google… Hopefully you will also gain a deeper understanding of ssh so that you are more likely to impliment this rather than telnet.

Part 1 – Getting SSH ported

First thing’s first, you have to download and install CygWin. This allows you to have a Linux kernel run on top of your unstable windows box. You can get it from http://www.cygwin.com/ (when you install it, make sure you include the GCC compiler and the make functionality components.)

Now you might be thinking ahead and ask yourself, “Well why don’t I just install CygWin and then install SSH and run the daemon from there?” My answer to that is, “What happens when you want to run an ssh server in an environment where you cannot install cygwin”

What I did (and you can use OpenSSH if you want) is download the last release of the source code from ssh.com. From there, I did a ./configure ./make ./make install

Now that SSH is installed you can start copying files out of it and putting them in your own folders since CygWin compiles Linux source into .exe files J

The following is a list of files that I copied (it will give you at least the basic features, you can copy more if you desire more functionality)

From [cygwin]/bin to /bin:

bash.exe
cat.exe
chmod.exe
cp.exe
cygcrypt-0.dll
cygiconv-2.dll
cygintl-1.dll
cygintl-2.dll
cygwin1.dll
dir.exe
dircolors.exe
find.exe
hostkey
hostkey.pub
ls.exe
mkdir.exe
mkpasswd.exe
mv.exe
random_seed
rm.exe
rmdir.exe
sftp-server2.exe
sh.exe
sshd2.exe
tcpd.exe


From [cygwin]/etc to /etc:
bash.bashrc
DIR_COLORS
profile

From [cygwin user directory]/.ssh to [windows user directory]/.ssh
authorization
sshd2_config
[your public key (formatted for ssh.com)]

From [user directory] to [user directory]:
.bashrc

I recommend that you copy the .ssh directory rather than try to create it since if you try to do it in windows it will say that you need to put a name in for the directory.

Part 2 – Configuring your SSH server

Once you have these files you will want to run mkpasswd.exe so that the file ownerships are correctly listed. [Sidenote: you may also want to run this because they you may (with a little tweaking) be able to login using usernames/passwords]

Next you will want to put the /bin directory into your path (right click my computer -> properties -> advanced tab -> environment variables button)

From here you have 2 options you could create 2 batch files and start/stop your ssh server using them OR you could create a windows service and run your ssh server from there

If you want to create 2 batch files:
I created 2 batch files (because it was quicker and easier) here are their names and their contents:

Name: Start SSH Server.bat
Contents:
@echo off
sshd2

Name: Stop SSH Server.bat
Contents:
@echo off
tskill sshd2
tskill sh
tskill sftp-server2
tskill bash
tskill tcpd

[Sidenote: you may have to change the tskill command because I don’t remember if Windows 2k uses this command]

From there I created shortcuts on the desktop and BAM it works 

If you want to create a windows service:
I used a tool made by Microsoft called srvinstw.exe which comes with the Windows 2k resource kit but works on Windows XP it is a gui for the “sc create” command and is attached to the end of this tutorial.

If you want to create the service manually here are the registry keys that I made (you can copy and paste them into a .reg file if you want to import them directly.

Ssh.reg:
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SSH Server]
"Type"=dword:00000010
"Start"=dword:00000002
"ErrorControl"=dword:00000001
"ImagePath"=hex(2):63,00,3a,00,5c,00,62,00,69,00,6e,00,5c,00,73,00,73,00,68,00,\
64,00,32,00,2e,00,65,00,78,00,65,00,00,00
"DisplayName"="SSH Server"
"ObjectName"="LocalSystem"

[Sidenote: using this registry entry will automatically start the SSH server automatically when you start your computer. Furthermore, I STRONGLY recommend that you do not install the service this way because your system security will not be automatically installed with this]

Part 3 – Key Generation and Final Configuration tips

Now that you have an SSH server installed, you have to give yourself access to it. The directions I have given to you do not allow keyboard authentication but rather PKI (Public Key Authentication).

Download puttygen from http://the.earth.li/~sgtatham/putty/...6/puttygen.exe
Generate a key [Sidenote: I always use SSH2 DSA 1024 bit encryption] and put a password on your key and save the public and the putty private key.

Now for this key to be authorized to work you must put the public key on your ssh server in the [user directory]/.ssh directory and add the following line to a file called authorization:

key [key name]

Finally you have to modify the sshd2_config file so that it will know where stuff is. Here are the lines you have to modify (don’t forget to remove the # at the beginning of the line):
HostKeyFile /bin/hostkey
PublicHostKeyFile /bin/hostkey.pub
RandomSeedFile /bin/random_seed
Port 22
ListenAddress any
ResolveClientHostName yes
KeepAlive yes
CheckMail no
AuthorizationFile authorization
AllowedAuthentications publickey
Ssh1Compatibility no
subsystem-sftp sftp-server2

Final Final tips:
You can restrict what users can/can’t log on (good for mixed environments where you want access via ssh but you don’t want any other users to get the bright idea that they can have access also)
AllowUsers sj.*,s[[:digit:]]*,s(jl|amza)
DenyUsers skuuppa,warezdude,31373

You can also filter by IP addresses and Subnets.
AllowHosts \i192.168.1.100

Orient yourself with the sshd2_config file and you will be able to further customize ssh to your likings.

If you install SSH as a service it will not kill all sub processes when it closes. You may still want to keep the stop ssh server batch file handy

finally, if you want the quick dirty way you can go to http://sshwindows.sourceforge.net/ and download a pre-made already configured version of openssh for windows