【问题标题】:setting up ssh-keys for bitbucket account (with mac osx)为 bitbucket 帐户设置 ssh 密钥(使用 mac osx)
【发布时间】:2016-11-11 03:43:03
【问题描述】:

我有一个BitBucket 帐户。尽管在计算机上设置了ssh key,然后将其添加到我的bitbucket 帐户中,但我无法连接:

$ git clone git@bitbucket.org:my-account/myrepo.git 
Cloning into 'myrepo'...
conq: repository does not exist.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我做了以下事情:

$ cd ~/.ssh

$ ssh-keygen -f ~/.ssh/my-key -N ''

$ vim config
Host bitbucket.org
  HostName bitbucket.org
  IdentityFile ~/.ssh/my-key

$ ls -l
-rw-------  1 me  ...   229 Jul  8 15:50 config
-rw-------  1 me  ...  1679 Jul  8 14:07 my-key
-rw-r--r--  1 me  ...   411 Jul  8 14:07 my-key.pub

然后我将 my-key.pub 的内容添加到我的 bitbucket 帐户的 ssh keys 中。然后我重新尝试克隆我的repository

$ git clone git@bitbucket.org:my-account/myrepo.git 
Cloning into 'myrepo'...
conq: repository does not exist.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我在另一台机器上重复了相同的过程,它成功了:

$ git clone git@bitbucket.org:my-account/myrepo.git
Initialized empty Git repository in /home/me/.ssh/myrepo/.git/
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.

我现在需要在我的第一台机器上做同样的事情。 作为最后的手段,我使用 ssh-agent 在网上遵循了一些建议:

$ eval `ssh-agent -s`
$ ssh-add ~/.ssh/my-key

但还是没有运气:

$ git clone git@bitbucket.org:my-account/myrepo.git 
Cloning into 'myrepo'...
conq: repository does not exist.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

我不知道第一台机器有什么不同,为什么它拒绝我的请求?


编辑 1

当然,正如D.Samchuk 所建议的那样,我尝试了非常基本的方法:

生成 id_rsa

$ ssh-keygen -t rsa
enterx3

复制了密钥的确切内容

$ cat ~/.ssh/id_rsa.pub

我在我的 BitBucket 帐户的 ssh 密钥中添加了 id_rsa.pub 的内容。

Git 克隆仍然不允许我访问存储库,并显示与上面相同的输出错误消息。


编辑 2

我不知道这可能与mac配置有关吗?由于另一台机器是redhat linux,我只是想知道但找不到任何报告的类似问题。

【问题讨论】:

  • 我投票结束这个问题,因为它不是关于编程的。试试apple.stackexchange.com
  • 我同意你很抱歉给您带来的麻烦。

标签: macos bitbucket ssh-keys ssh-agent


【解决方案1】:

只需执行以下操作:

$ ssh-keygen -t rsa

名称:id_rsa

密码:只需按两次回车键即可避免每次连接时打印关键字

$ cat ~/.ssh/id_rsa.pub

复制输出

打开 bitbucket --> 配置文件 --> bitbucket 设置 --> 添加 ssh 密钥 --> 粘贴您的输出

【讨论】:

  • 这是我在尝试使用单独的 ssh 密钥制作自己的配置文件之前所做的第一件事。尽管如此,我删除了我的 ssh 密钥,我的 ssh 配置文件,我按照您的步骤操作,git clone 不允许我访问存储库,同样的错误。
【解决方案2】:

如果您没有使用 ssh 密钥的密码,则不需要 ssh-agent

https://help.github.com/articles/working-with-ssh-key-passphrases/

【讨论】:

    【解决方案3】:

    解决了。当我深入研究这个问题时,我发现它绝对与ssh 键无关,而是与错误消息提示的缺少存储库有关。这一切都是关于使用git config --global 来试验全局配置,这弄乱了我在那台计算机上的 git 配置。我在这里的另一个线程中详细说明了我的步骤:https://unix.stackexchange.com/questions/294780/git-retains-remote-information-from-a-deleted-repository/294809#294809

    【讨论】:

      猜你喜欢
      • 2016-08-17
      • 1970-01-01
      • 2016-07-01
      • 2018-02-21
      • 2020-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多