ssh-add -k ~/.ssh/id_rsa
AddKeysToAgent yes
How to fix
I fixed this by entering the following commands:
$ ssh-agent bash
This creates a new bash process that allows you to add private keys. When adding a new private key you will be prompted for the passphrase once and only once.
nd then:
$ ssh-add /home/username/.ssh/id_rsa
Enter passphrase for /home/username/.ssh/id_rsa:
Identity added: /home/username/.ssh/id_rsa (/home/username/.ssh/id_rsa)
...where username is your username. You can do the same using $USER variable:
$ ssh-add /home/$USER/.ssh/id_rsa
Alternatively, just use ~ for your home directory.
$ ssh-add ~/.ssh/id_rsa
And the problem was fixed.