我上传了我的~/.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——


当前回答

如果您使用的是Ubuntu系统,请使用以下方法永久存储密码:

git config --global credential.helper store

其他回答

如果你仍然得到太多的身份验证失败错误:

nano ~/.ssh/config

粘贴:

Host bitbucket_james
    HostName bitbucket.org
    User james
    Port 22
    IdentitiesOnly=yes
    IdentityFile=~/.ssh/id_rsa_bitbucket_james

最重要的是-你应该bitbucket_james的别名而不是bitbucket.org当你设置你的远程URL:

git remote set-url origin git@bitbucket_james:repo_owner_user/repo_name.git

下面假设通过iTerm / Terminal命令行访问bitbucket。

对于MacOS Sierra 10.12.5,我的系统出现了一个同样的问题——在每个连接到bitbucket时都要求我的SSH密码。

此问题与macOS 10.12.2中的OpenSSH更新有关,此处的技术说明TN2449中对此进行了描述。

您很可能想要定制您的解决方案,但是当添加到您的~/时,以下内容将会起作用。ssh /配置文件:

Host *
    UseKeychain yes

有关ssh配置的更多信息,请查看ssh_config的手册页:

% man ssh_config

还有一件事:这里有一篇关于超级用户的很好的文章,讨论了这个问题,并根据您的需求和设置提供了各种解决方案。

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

你好,来自未来的谷歌人。

在MacOS >= High Sierra操作系统下,由于某些原因SSH密钥不再保存到KeyChain中。

使用ssh-add -K也不能在重启后存活。

这里有3种可能的解决方案。

我已经成功地使用了第一种方法。我在~/.ssh中创建了一个名为config的文件:

Host *
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_rsa