Setting up an Open SSH Server (sshd) on Windows

Set up Cygwin & SSH Server on Windows 7

1a. Download Cygwin -
1b. Run setup.exe
1c. Choose an install location. C:\cygwin is fine (I typically have it 1 more level up with all of my dev tools. Something like C:\dev\cygwin)
1d. Choose a package location C:\cygwin\packages (I like to keep everything together)
1e. For Internet Connection, Choose Direct Connection
1f. For Download Site, Pick an http one that looks fast or close.
1g. For Package Selection, select at least the following:
Net > OpenSSH
Net > OpenSSL
1h. Finish the install, then Click Start > All Programs > Cygwin > (Right click) Cygwin Bash Shell. Then Select "Run as Administrator."

1i. Run mkpasswd and mkgroup (if your are part of a domain then add the -d)
mkpasswd -l [-d] > /etc/passwd
mkgroup -l [-d] > /etc/group

e.g. If you are at home:
mkpasswd -l > /etc/passwd
mkgroup -l > /etc/group

e.g. If you are at work:
mkpasswd -l -d > /etc/passwd
mkgroup -l -d > /etc/group

1j Run "ssh-host-config":
scott@eng01 ~
$ ssh-host-config
*** Info: Generating /etc/ssh_host_key
*** Info: Generating /etc/ssh_host_rsa_key
*** Info: Generating /etc/ssh_host_dsa_key
*** Info: Creating default /etc/ssh_config file
*** Info: Creating default /etc/sshd_config file
*** Info: Privilege separation is set to yes by default since OpenSSH 3.3.
*** Info: However, this requires a non-privileged account called 'sshd'.
*** Info: For more info on privilege separation read /usr/share/doc/openssh/READ
*** Query: Should privilege separation be used? (yes/no)

1k. (Type yes to the Query question)

*** Info: Note that creating a new user requires that the current account have
*** Info: Administrator privileges. Should this script attempt to create a
*** Query: new local account 'sshd'? (yes/no)

1l. (Type yes to the Query question)

*** Warning: The following functions require administrator privileges!
*** Query: Do you want to install sshd as a service? (yes/no)

1m. (Type yes to the Query question)

*** Query: Enter the value of CYGWIN for the daemon: []

1n. Enter: "ntsec tty"

*** Info: On Windows Server 2003, Windows Vista, and above, the
*** Info: SYSTEM account cannot setuid to other users -- a capability
*** Info: sshd requires. You need to have or to create a privileged
*** Info: account. This script will help you do so.

*** Info: You appear to be running Windows 2003 Server or later. On 2003
*** Info: and later systems, it's not possible to use the LocalSystem
*** Info: account for services that can change the user id without an
*** Info: explicit password (such as passwordless logins [e.g. public key
*** Info: authentication] via sshd).

*** Info: If you want to enable that functionality, it's required to create
*** Info: a new account with special privileges (unless a similar account
*** Info: already exists). This account is then used to run these special
*** Info: servers.

*** Info: Note that creating a new user requires that the current account
*** Info: have Administrator privileges itself.

*** Info: No privileged account could be found.

*** Info: This script plans to use 'cyg_server'.
*** Info: 'cyg_server' will only be used by registered services.
*** Query: Do you want to use a different name? (yes/no)

1o. Enter "no"

*** Query: Create new privileged user account 'cyg_server'? (yes/no) yes
*** Info: Please enter a password for new user cyg_server. Please be sure
*** Info: that this password matches the password rules given on your system.
*** Info: Entering no password will exit the configuration.
*** Query: Please enter the password:

1p. Enter something you can remember.

*** Info: User 'cyg_server' has been created with password 'cyg_server'.
*** Info: If you change the password, please remember also to change the
*** Info: password for the installed services which use (or will soon use)
*** Info: the 'cyg_server' account.

*** Info: Also keep in mind that the user 'cyg_server' needs read permissions
*** Info: on all users' relevant files for the services running as 'cyg_server'.

*** Info: In particular, for the sshd server all users' .ssh/authorized_keys
*** Info: files must have appropriate permissions to allow public key
*** Info: authentication. (Re-)running ssh-user-config for each user will set
*** Info: these permissions corrently. [Similary restrictions apply, for
*** Info: instance, for .rhosts files if the rshd server is running, etc].

*** Info: The sshd service has been installed under the 'cyg_server'
*** Info: account. To start the service now, call `net start sshd' or
*** Info: `cygrunsrv -S sshd'. Otherwise, it will start automatically
*** Info: after the next reboot.

*** Info: Host configuration finished. Have fun!

1q. Type "net start sshd"

(Wait a couple minutes for this service to start for the first time)

1r. You can now connect to your server.
ssh localhost

1s. If you have Windows Firewall enabled, you will need to allow access to port 22