I uploaded my ~/.ssh/id_rsa.pub
to Bitbucket\'s SSH keys as explained, but Git still asks me for my password at every operation (such as git pull
).
Are you sure you cloned it using the ssh url?
The url for origin says url = https://Nicolas_Raoul@bitbucket.org/Nicolas_Raoul/therepo.git
so if it is using https it will ask for password irrespective of your ssh keys.
So what you want to do is the following:
open your config file in your current repo ..
vim .git/config
and change the line with the url from
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = https://Nicolas_Raoul@bitbucket.org/Nicolas_Raoul/therepo.git
to
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@bitbucket.org:Nicolas_Raoul/therepo.git
I was having other weirdness around logging in. I came across something that seemed totally dumb but worked in my case. Simply go to MacOS's keychain. Find the login lock icon in the sidebar. Click it to logout and then click to login. Sounds dumb but it solved my issues. Worth a shot.
Hello Googlers from the future.
On MacOS >= High Sierra, the SSH key is no longer saved to the KeyChain because of reasons.
Using ssh-add -K
no longer survives restarts as well.
Here are 3 possible solutions.
I've used the first method successfully. I've created a file called config
in ~/.ssh
:
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
None of these answers helped me, turned out my issue was slightly different. It was ssh that was asking for my password each time, before sending the key. So what I had to do was link my password with this command:
ssh-add -K ~/.ssh/id_rsa
It'll then prompt you for your password and store it. This could be the solution you're looking for if each time your prompted for a password it says
Enter passphrase for key '/Users//.ssh/id_rsa':
More info here
NOTE: I used this on my mac machine successfully, but as @Rob Kwasowski pointed out below, the upper case K
option is unique to mac. If not on mac you will need to use lowercase k
(which probably works for mac too but I haven't tested).
Its already answered above. I will summarise the steps to check above.
run git remote -v
in project dir. If the output shows remote url starting with https://abc
then you may need username password everytime.
So to change the remote url run git remote set-url origin {ssh remote url address starts with mostly git@bitbucket.org:}
.
Now run git remote -v
to verify the changed remote url.
Refer : https://help.github.com/articles/changing-a-remote-s-url/
The following assumes command-line access via iTerm / Terminal to bitbucket.
For MacOS Sierra 10.12.5, my system manifested an equivalent problem - asking for my SSH passphrase on each connection to bitbucket.
The issue has to do with OpenSSH updates in macOS 10.12.2, which are described here in Technical Note TN2449.
You very well might want to tailor your solution, but the following will work when added to your ~/.ssh/config file:
Host *
UseKeychain yes
For more information on ssh configs, take a look at the man pages for ssh_config:
% man ssh_config
One other thing: there is a good write-up on superuser here that discusses this problem and various solutions depending on your needs and setup.