Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git on Bitbucket: Always asked for password, even after uploading my public SSH key

Tags:

git

ssh

bitbucket

People also ask

How do I stop Git from asking for password?

You can avoid being prompted for your password by configuring Git to cache your credentials for you. Once you've configured credential caching, Git automatically uses your cached personal access token when you pull or push a repository using HTTPS.

Why does SSH always ask for passphrase?

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.


Are you sure you cloned it using the ssh url?

The url for origin says url = https://[email protected]/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://[email protected]/Nicolas_Raoul/therepo.git

to

[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = [email protected]:Nicolas_Raoul/therepo.git

As explained here, if you clone with SSH url, you don't need to enter username / password each time you push / pull. Check above answer by @manojlds

But if you want to clone with HTTPS and want to avoid entering username / password each time, you can store credentials into cache with below command:

git config --global credential.helper 'cache --timeout 3600'

where 3600 (seconds) means 1 hour, you may change it as per your requirement.


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 [email protected]:}.

Now run git remote -v to verify the changed remote url.

Refer : https://help.github.com/articles/changing-a-remote-s-url/


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