In my situation, I'm running Ubuntu on VMWare on top of my Windows 7 desktop. My goal here is to set up passwordless SSHing so I can scp and SSH from Ubuntu to Windows (and vice versa) without being prompted for a password.

To save yourself a load of trouble-shooting later, first make sure you have these packages installed with Cygwin. If you already have Cygwin installed, just run setup.exe again and it will let you add these packages on top of what you already have. The packages you need are openssh, tcp_wrappers, and vim.

To install these packages, perform the following: Run setup.exe, pick directory, pick mirror, then click the View button for "Full" view .

Find the packages listed above by typing the names in the search field, you must do this one at a time. Upon finding a package, click the word Skip until you see an X appear in column B, then move on to the next package.

Finish installation and start Cygwin.
Type "ssh-host-config", this will install a service that you need in order to SSH into Cygwin.
Answer yes to all questions as prompted until installation completes.
Now type "cygrunsrv -S sshd" to start the service that you just installed. At this point you should also have “Cygwin sshd” available as a service that you can start and stop from start->control panel->administrative tools->computer management – go to the services and applications->services list.

Now we must allow hosts to SSH to your Cygwin with TCP wrappers. Type "vim /etc/hosts.allow" in Cygwin.
Put the line "sshd: ALL : allow" ABOVE the line "ALL : PARANOID : deny". Just delete the current sshd line, add a line above the paranoid line, and then retype the sshd line. If you're not familiar with vi, press i to start typing, use arrow keys to move. Once this is done, hit <escape> then :wq <enter>.

Try to SSH into Cygwin from your virtual Ubuntu client or whatever you're using (type ipconfig into Cygwin to obtain your local IP, or whatismyip.com if you need to obtain your internet IP).

If all goes well, on to SSH key generation!

The following instructions are assuming you're treating Cygwin as the server and your other terminal as the client. If it's the opposite in your case (if you'd like to SSH from Cygwin to the other terminal with no password) then reverse the instructions so that what's done on Cygwin in my instructions is done on the other terminal and vice versa. Furthermore, if you'd like to be able to SSH from either and not be prompted for a password, follow this set of instructions as they are, then reverse, and repeat.

On your client (in my case, Ubuntu in VMWare) type "ssh-keygen -t rsa".
Hit enter 3 times.
Type "cd /home/user/.ssh" (replacing user with your username).
Now, "scp id_rsa.pub user@serverip:/home/user/.ssh" Replace user and serverip with their appropriate values.
Now, "ssh user@serverip" it should still prompt you for a password.
Once you have SSH'd to the server, navigate to .ssh directory "cd /home/user/.ssh".
Type "cat id_rsa.pub > authorized_keys2".
Type "cd .. ; chmod 700 .ssh" this changes the permissions on the .ssh folder.
Type "exit".
Try to SSH back, and it should not prompt for a password.

Special thanks to these sites, please visit: http://chinese-watercolor.com/LRP/printsrv/cygwin-sshd.html       http://mugurel.sumanariu.ro/windows/how-to-configure-cygwin-for-sshd/

Last revised: 4/16/2011

Contact me via email: admin@tr1x.com