我上传了我的~/.ssh/id_rsa。但是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可以正常工作。 . ssh rwx -, . ssh / id_rsa - r -------, . ssh / id_rsa。Pub是-rw-r——r——


当前回答

这里的关键字是'ssh://'而不是https://':-)

在你的。git/config中

请注意!如果你已经克隆了存储库,在你将你的公钥添加到BitBucket后,这些存储库可以重新克隆。这可能比侵入你的配置文件更干净;-)

其他回答

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

url的来源说url = https://Nicolas_Raoul@bitbucket.org/Nicolas_Raoul/therepo.git,所以如果它是使用https,它会要求密码,不管你的ssh密钥。

所以你要做的是:

在当前的repo中打开配置文件。

一个git / problem。

并更改包含url的行

[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

您可能需要仔细检查您的SSH身份文件。你可能会引导BitBucket查看你在BitBucket中保存的等效公钥的不同/不正确的私钥。

用尾巴检查~/。Ssh /config -你会看到类似的东西:

Host bitbucket.org
 HostName bitbucket.org
 IdentityFile ~/.ssh/personal-bitbucket-ssh-key

请记住,添加额外的身份(如工作和家庭)可以通过ssh-add命令完成,例如:

ssh-keygen -t rsa -C "companyName" -f "companyName"
ssh-add ~/.ssh/companyName

一旦你确认了哪个私钥在本地被查看,你就可以获取你的公共等价密钥,在这种情况下:

cat ~/.ssh/personal-bitbucket-ssh-key.pub | pbcopy

然后把密码粘贴到BitBucket上。你的git推送现在将被允许(前提是你使用的是前面提到的答案所指出的SSH克隆)没有密码,因为你的设备是一个公认的友好。

希望这能帮你弄清楚。

步骤1:安装git-credential-winstore https://confluence.atlassian.com/bitbucketserver/permanently-authenticating-with-git-repositories-776639846.html 步骤2:git配置——global credential。Helper '缓存超时3600' 这将存储您的密码1小时 步骤3:执行git命令 这将提示您输入密码,并提示凭据 并保存密码

上面已经回答了。我将总结上述检查步骤。

在项目目录下运行git remote -v。如果输出显示以https://abc开头的远程url,那么您可能每次都需要用户名和密码。

因此,要更改远程url,请运行git remote set-url origin {ssh远程url地址以git@bitbucket.org:}开头。

现在运行git remote -v来验证修改后的远程url。

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

在HTTP请求的情况下,也可以直接将凭据(带密码)粘贴到url中:

http://username:password@bitbucket.org/...

这样就省去了每次都要提交你的证书的麻烦。简单地修改你的.git/config (url)。