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