我上传了我的~/.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 url克隆,您不需要在每次推/拉时输入用户名/密码。检查上面@manojlds的回答

但是如果你想要使用HTTPS进行克隆,并且希望避免每次都输入用户名/密码,你可以使用以下命令将凭据存储到缓存中:

Git配置——全局凭据。Helper '缓存超时3600'

其中3600(秒)表示1小时,您可以根据自己的需求更改。

其他回答

我用我的用户名而不是电子邮件登录,它开始工作。

步骤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命令 这将提示您输入密码,并提示凭据 并保存密码

您确定您使用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

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

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

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

我用HTTPS URL克隆了存储库,而不是SSH URL,因此即使在添加SSH密钥后,它也在Bash Shell上询问我的密码。

我只是编辑了。/。并通过简单地将https://替换为ssh://来改变url变量的值

E.g.

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

更改为:

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