【问题标题】:IntelliJ - How to use a different ssh keyIntelliJ - 如何使用不同的 ssh 密钥
【发布时间】:2011-06-11 23:19:15
【问题描述】:

我有 2 个 github 帐户 一个公司一个个人一个

我使用 cygwin 管理我的 ssh 密钥并连接到 Github

在 IntelliJ 中使用公司帐户时一切正常,因为它使用默认的 .ssh/id_rsa 密钥

使用我的个人帐户在 Cygwin 中一切正常,因为我可以使用“ssh-add ~/.ssh/ide_rsa_otherkeyfile”命令,然后通过命令行使用所有 git 命令

但 IntelliJ 始终默认使用“id_rsa”文件,因此我无法连接到我的个人存储库。

IntelliJ 有没有办法使用另一个 rsa 密钥?

所有这些 RSA 和 cygwin 都远高于我的 linux 命令行经验水平。

注意: 我还在 .ssh 目录中创建了配置文件,以方便多个 github 帐户

Default GitHub user (corporate account) 
Host github.com HostName
github.com User git IdentityFile/Users/username/.ssh/id_rsa

Client user (personal account)
Host github-client
HostName github.com
User git IdentityFile /Users/username/.ssh/id_rsa_perso

简而言之,它的作用是告诉 SSH 在连接到服务器 github-client 时使用客户端密钥,这实际上是 github.com。

如果没有人有解决方案,我知道邀请我的公司帐户作为贡献者会更容易,但我会在 2 个单独的电子邮件帐户下提交。

【问题讨论】:

  • 如果 IntelliJ 确实尊重配置文件,使用像 github-client:aGitRepoName 这样的地址应该足以让 IntelliJ 使用其他 ssh 密钥。

标签: git github intellij-idea rsa


【解决方案1】:

从版本控制系统检出您的项目时,请使用<host-from-ssh-config>:<github-username>/<repository> 格式,如提到的VonC

$ cat ~/.ssh/config
Host github.com-activehacker
    HostName github.com
    User git
    IdentityFile /Users/andrey/.ssh/id_rsa_activehacker

【讨论】:

    【解决方案2】:

    来自Using Git integration

    IntelliJ IDEA 支持使用多个 ssh 密钥的标准方法, 通过创建 .ssh/config 文件。

    【讨论】:

      猜你喜欢
      • 2021-03-09
      • 2013-02-20
      • 2021-01-27
      • 1970-01-01
      • 2019-02-12
      • 1970-01-01
      • 2021-09-09
      • 2011-10-08
      • 1970-01-01
      相关资源
      最近更新 更多