Warm tip: This article is reproduced from serverfault.com, please click

其他-Bitbucket上的Git:即使上传了我的公共SSH密钥,也总是要求输入密码

(其他 - Git on Bitbucket: Always asked for password, even after uploading my public SSH key)

发布于 2011-12-22 07:28:48

我已按照说明~/.ssh/id_rsa.pub我上传Bitbucket的SSH密钥,但是Git在每次操作(例如)时仍会要求我提供密码我错过了什么?git pull

它是一个私有存储库(另一个人的私有存储库的叉子),我将其克隆为:

git clone git@bitbucket.org:Nicolas_Raoul/therepo.git

这是我的本地人.git/config

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = https://Nicolas_Raoul@bitbucket.org/Nicolas_Raoul/therepo.git
[branch "master"]
        remote = origin
        merge = refs/heads/master

在具有相同公钥的相同环境中,Github上的Git可以正常工作。
.sshrwx------.ssh/id_rsa-rw-------.ssh/id_rsa.pub-rw-r--r--

Questioner
Nicolas Raoul
Viewed
0
7,170 2019-11-14 22:45:38

你确定使用ssh url克隆了它吗?

原始网址表示,url = https://Nicolas_Raoul@bitbucket.org/Nicolas_Raoul/therepo.git因此,如果使用的是https,则无论输入的ssh密钥如何,都会要求输入密码。

因此,你需要执行以下操作:

在你当前的仓库中打开你的配置文件。

vim .git/config

并更改网址为

[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = https://Nicolas_Raoul@bitbucket.org/Nicolas_Raoul/therepo.git

[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = git@bitbucket.org:Nicolas_Raoul/therepo.git