【问题标题】:Two different Github accounts in the same RStudio同一个 RStudio 中的两个不同的 Github 帐户
【发布时间】:2018-03-22 13:39:06
【问题描述】:

我可以为不同的 GitHub 帐户管理多个 SSH 密钥,以便我可以访问多个帐户和项目,每个帐户和项目都具有不同的凭据。但是,我是否可以在同一个 RStudio 中使用两个不同的 github 帐户(推和拉)处理两个不同的项目?我在网上搜索但找不到答案。我的文件夹中有相关的 SSH 密钥。但是,我无法在 RStudio 的全局选项中更改 SSH RSA 密钥,因为它总是放置文件~/.ssh/id_rsa。但我还有另一个 Github 帐户 ~/.ssh/id_rsa_SECOND 的密钥。我将不胜感激任何帮助!谢谢!

编辑: 我的配置文件有,

Host me.github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile Clone  ~/.ssh/id_rsa

Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_SECOND

这告诉我使用 me.github.com 而不是 github.com 作为第一个 Github 帐户中存储库的主机(身份为 ~/.ssh/id_rsa)并使用 github.com 作为第二个 Github 帐户中的存储库(具有身份 ~/.ssh/id_rsa_SECOND)。但是,当我在个人帐户中克隆存储库时,使用 git@ **me**.github.com:username/hugo-academic.git 不起作用。

【问题讨论】:

标签: github rstudio ssh-keys


【解决方案1】:

这是一个老问题,但如果其他人遇到这个问题,解决方案(对我来说)是在 ~/.ssh/config 的每个块中包含 github 用户名。如:

# USERNAME-1 at github:                                                                                                                                                          
Host github.com-1
  HostName github.com
  User USERNAME-1
  IdentityFile ~/.ssh/id_rsa_1
  IdentitiesOnly yes
# USERNAME-2 at github:                                                                                                                                                           
Host github.com-2
  HostName github.com
  User USERNAME-2
  IdentityFile ~/.ssh/id_rsa_2
  IdentitiesOnly yes

在 github URL 中,根据需要将“github.com”更改为“github.com-1”或“github.com-2”,例如,您可以使用以下代码进行克隆:

git clone git@github.com-1:USERNAME-1/foo.git

代替:

git clone git@github.com:USERNAME-1/foo.git

【讨论】:

    【解决方案2】:

    根据 Microsoft's Windows Credential Manager 文档,查看 useHttpPath 设置(您的 credential.namespace 可能会有所不同。在我的情况下是 github.com):

    git config --global credential.github.com.useHttpPath true
    

    【讨论】:

      猜你喜欢
      • 2019-07-10
      • 1970-01-01
      • 2021-12-20
      • 1970-01-01
      • 2021-03-28
      • 2020-10-18
      • 2022-12-11
      • 1970-01-01
      • 2020-06-02
      相关资源
      最近更新 更多