SSH Key - Still asking for password and passphrase
Add Identity without Keychain
There may be times in which you don't want the passphrase stored in the keychain, but don't want to have to enter the passphrase over and over again.
You can do that like this:
ssh-add ~/.ssh/id_rsa
This will ask you for the passphrase, enter it and it will not ask again until you restart.
Add Identity Using Keychain
As @dennis points out in the comments, to persist the passphrase through restarts by storing it in your keychain, you can use the -K
option (-k
for Ubuntu) when adding the identity like this:
ssh-add -K ~/.ssh/id_rsa
Once again, this will ask you for the passphrase, enter it and this time it will never ask again for this identity.
If you work with HTTPs
urls, it'll always ask for your username / password.
If you're correctly using SSH
when cloning / setting remotes. Then make sure you have a ssh-agent to remember your password. That way, you'll only enter your passphrase once by terminal session.
If it is still too annoying, then simply set a ssh-key without passphrase.
On Mac OSX you can add your private key to the keychain using the command:
ssh-add -K /path/to/private_key
If your private key is stored at ~/.ssh and is named id_rsa:
ssh-add -K ~/.ssh/id_rsa
You will then be prompted for your password, which will be stored in your keychain.
Edit - Handle restart
In order to not have to fill in your password even after a restart add the following to your ssh configuration file (commonly located at ~/.ssh/config)
Host * UseKeychain yes AddKeysToAgent yes IdentityFile ~/.ssh/id_rsa