# Cygwin: Run SSH.exe (without cygwin.bat) with a keypair

I have a box I'm trying to create an SSH tunnel to using a keypair without a password. If I run cygwin.exe and generate a keypair without a password using ssh-keygen and put the public key on the server I can use ssh to create a tunnel between the 2 boxes no problem.

My question though is this. Can I do this without having to run cygwin.bat and use ssh.exe directly from a command prompt.

When I try this I am prompted for the user's password and it is not using the keypair. I'm assuming that when I run cygwin.exe it is loading up my usr directory and using the keypair from the .ssh directory and when I run ssh.exe directly it is not loading my usr directory and therefore it is not trying to use the keypair and is prompting me for my password.

How do I solve this problem?

-

ssh looks in \$HOME/.ssh/id_* for your keys, so you can set the HOME environment variable.
set HOME=path\to\your\home

(I'm not sure about where Cygwin puts your homedir, but set HOME=%USERPROFILE% should work.)