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

前端 未结 15 1274
情书的邮戳
情书的邮戳 2020-12-22 17:32

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).

相关标签:
15条回答
  • 2020-12-22 18:16

    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.

    0 讨论(0)
  • 2020-12-22 18:16
    • Step 1: Install git-credential-winstore
      https://confluence.atlassian.com/bitbucketserver/permanently-authenticating-with-git-repositories-776639846.html

    • Step 2: git config --global credential.helper 'cache --timeout 3600'
      This will store your password for 1 hour

    • Step 3: Run a git command that will prompt you for your password and the credential will prompt and store your password
    0 讨论(0)
  • 2020-12-22 18:17

    I cloned the repository with HTTPS URL instead of SSH URL hence even after adding the SSH Key it was asking me for password on Bash Shell.

    I just edited the ./.git/config file and changed the value of url variable by simply replacing the https:// to ssh://

    E.g.

    [core]
            ...
            ...
            ...
    [remote "origin"]
            url = https://<username>@bitbucket.org/<username>/<repository_name>.git
            fetch = +refs/heads/*:refs/remotes/origin/*
            ...
            ...
            ...
    

    Changed to:

    [core]
            ...
            ...
            ...
    [remote "origin"]
            url = ssh://<username>@bitbucket.org/<username>/<repository_name>.git
            fetch = +refs/heads/*:refs/remotes/origin/*
            ...
            ...
            ...
    
    0 讨论(0)
提交回复
热议问题