【问题标题】:Cannot get multiple ssh keys to work with BitBucket using aliases无法使用别名获取多个 ssh 密钥以与 BitBucket 一起使用
【发布时间】:2017-01-17 16:48:38
【问题描述】:

我有两个 bitbucket 帐户,一个用于个人资料,一个用于工作。我个人的工作正常,我在工作中使用的也工作正常;但是,我希望能够在家中连接到工作,但我无法让它工作。

我的文件被称为:

## Unrelated ones I use for plan.io that still work

id_rsa
id_rsa.pub

## Personal one for bitbucket I just created because of seperation

homeid
homeid.pub

## Work one for bitbucket

workid
workid.pub

我的配置文件如下:

Host home@bitbucket.org
 HostName bitbucket.org
 IdentityFile ~/.ssh/homeid


Host work@bitbucket.org
 HostName bitbucket.org
 IdentityFile ~/.ssh/workid

现在我对如何使用别名进行克隆有点困惑,但尝试了:

git clone work@bitbucket.org:my-username/myrepo.git

但它失败并显示错误消息:

Cloning into 'myrepo'...
Permission denied (publickey).
fatal: Could not read from remote repository.

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

我已将公钥添加到相应的 bitbucket 帐户中,所以不确定我在这里做错了什么?

【问题讨论】:

    标签: git ssh bitbucket ssh-keys ssh-keygen


    【解决方案1】:

    好的,解决了。

    我使用了错误的 git clone 地址,正确的是:

    git clone git@workid:my-username/myrepo.git
    

    ...但还必须将我的 config 文件更改为以下内容以更改主机:

    Host homeid
     HostName bitbucket.org
     IdentityFile ~/.ssh/homeid
    
    
    Host workid
     HostName bitbucket.org
     IdentityFile ~/.ssh/workid
    

    【讨论】:

      【解决方案2】:

      主持 home@bitbucket.org

      ssh_config Host 指令不接受“用户名@”语法。请改用Match 指令:

      Match user home host bitbucket.org
          HostName bitbucket.org
          IdentityFile ~/.ssh/homeid
      ...
      

      【讨论】:

      • 那么我该如何进行克隆呢? git clone home@bitbucket.org:my-username/myrepo.git ?
      猜你喜欢
      • 2014-07-29
      • 1970-01-01
      • 2019-01-19
      • 2013-10-19
      • 2014-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多