git - IntelliJ - 如何使用不同的 ssh key

标签 git github intellij-idea rsa

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

我使用 cygwin 来管理我的 ssh key 并连接到 Github

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

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

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

有没有办法让 IntelliJ 使用另一个 rsa key ?

所有这些 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 时使用客户端 key ,这实际上是 github.com。

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

最佳答案

从版本控制系统 check out 项目时,使用 <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

enter image description here

关于git - IntelliJ - 如何使用不同的 ssh key ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6319102/

相关文章:

Java字符串越界的愚蠢行为

git子模块 "--reference"参数

git - 如何查看git存储库中单个文件的文件大小历史记录?

git - 不能再推送到 github origin master

git - 如何在 Github 中 pull 请求后快速跟踪分支

git - PhpStorm 和 Git - 推送失败 - 失败,错误为 :

git - 尝试编译Gimp时无法编译gegl

git - 有没有一种方法可以通过 git 中的所有提交来更改文件的内容?

android-studio - 如何将 Gradle 项目链接到其依赖项的 Javadoc?

intellij-idea - IntelliJ全面屏,真的