Forward SSH keys for Capistrano deploys
The other days I was setting up a virtual server for one of my projects and the deploy is handled with Capistrano and it complained about the SSH classic —
Permission denied (publickey).
Usually I set up a new SSH key on the server and add it to Github or wherever I’m hosting my source code, but there is a much better way with SSH forwarding that doesn’t require adding any new keys. Edit
.ssh/config on your local machine and add
ForwardAgent yes for your server.
Host example.com ForwardAgent yes
After that, your key to SSH agent on your local machine by running the following.
If you are using Mac you’d have add your key after every restart of the system. To make it permanent, run the following line.
/usr/bin/ssh-add -K ~/.ssh/id_rsa
Now, every time you connect to the server with SSH your key is forwarded to that machine and it behaves as if it was physically present on that machine.
Would you like to get top 5 links on Programming every Monday?
Sign up to Programming Digest and stay up to date!
Did you like the article? Send me a comment!