New project, old problems.
Getting familiar with the 3.0 version of Capistrano (the guys deserve praise for adopting the Rake DSL) and immediately I stumbled on the old “SSH passwordless logins won’t work on Windows” problem.
It’s a myth, but you have to fumble a bit till it can work. Did this 4 or 5 years ago (and it was slightly more work) and had to do it again this week, so here’s a forgetmenot on how to get Capistrano 3.x to use SSH keys for passwordless login on Windows7.
Generate your keys
No reason to go through it (which saves me like half a dozen steps from this list), but if you’re on Windows and you use puttygen please note that you will need to export the keys in OpenSSH format and copy the exported public key in the authorized_keys file on the server side.
###Copy the OpenSSH format key in C:\Users\your_username\.ssh
Now, in the *ix world keys and configuration are expected in ~/.ssh by default. Where you keep them on Windows doesn’t really matter, the C:\Users\your_username\.ssh is just for conceptual consistency.
###Tell Capistrano where to find the keys
The default value for key location in Capistrano is the *ixy one (doh!) so on Windows you need to go the extra mile.
Now choosing C:\Users\your_username\.ssh gives us an advantage: Your keys are now in %USERPROFILE%\.ssh which means we can use the environment and get multiple user support for free. So in your stage deployment configuration set the Capistrano SSH options as follows:
do substitute key.id_rsa with whatever filename your keys are stored in plz ;)
Also depending on the server setup there might be a :forward_agent option there or not, but if you’re doing :forward_agent magic with the server you don’t need me to tell you how to setup your ssh options.