Generate .ssh key locally

cd ~/.ssh  

Generate a keypair. Give it a modified name, helps distinguish keys. Let’s go with ‘soup_rsa’

ssh-keygen -t rsa  

Copy public key to remote server.

scp soup_rsa.pub myserver:soup_rsa.pub  

SSH onto remote server

ssh soup  

If not already done, create ~/.ssh directory, then cd into `~/.ssh directory

Create authorized_keys directory

touch authorized_keys  

Move public key to ~/.ssh directory

mv ~/soup_rsa.pub ~/.ssh/  

Add public key to authorized keys

cat soup_rsa.pub >> authorized_keys  

Delete public key

rm soup_rsa.pub  

Exit server

Capistrano

  1. Add ssh config to deploy file
ssh_options[:forward_agent] = true  
ssh_options[:keys] = [File.join(ENV["HOME"], ".ssh", "soup_rsa")]  
  1. Ensure that private key lives on deployment server. Otherwise, you’ll be challenged with passwords during deploy.