SSH Key - Still asking for password and passphrase
回答1
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.
评论:
Note that this won't persist the identity on restarts. You can use the -K
option to store the passphrase in your keychain when adding it, e.g. ssh-add -K ~/.ssh/id_rsa
回答2
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.
评论:
回答3
If you're using windows, this worked for me:
eval `ssh-agent -s`
ssh-add ~/.ssh/*_rsa
It'll ask for passphrase in the second command, and that's it.
How to avoid being asked passphrase each time I push to Bitbucket
回答1
You need to use an ssh agent. Short answer: try
$ ssh-add
before pushing. Supply your passphrase when asked.
If you aren't already running an ssh agent you will get the following message:
Could not open a connection to your authentication agent.
In that situation, you can start one and set your environment up thusly
eval $(ssh-agent)
Then repeat the ssh-add
command.
It's worth taking a look at the ssh agent manpage.
回答2
Create (or edit if it exists) the following ~/.ssh/config file:
Host *
UseKeychain yes
AddKeysToAgent yes
IdentityFile ~/.ssh/id_rsa