Sometimes you need to create an SSH connection without entering in your password. For instance, you are syncing files using a Version Control System (such as Git or Mercurial) over SSH, and your software isn’t set up to ask for a password every time.

The solution is simple: Store a file on the target computer identifying the source computer.

Here’s how you do it:

1. Generate an SSH key on the source computer (the one you will be making the connection from). When prompted, don’t enter a passphrase.

ssh-keygen -t rsa

2. Create an .ssh directory on the target computer. Enter the ssh password when prompted.

ssh user@Target mkdir -p .ssh

3. Add the source computer’s ssh key to the list of allowed keys on the target computer

cat .ssh/id_rsa.pub | ssh user@Target 'cat >> .ssh/authorized_keys'

You should now be able to make a connection without entering a password.