我已成功将我的 GitHub 客户端配置为使用 SSH,并收到了来自 GitHub 的确认邮件,说明已添加新的 SSH key 。我也想将 IntelliJ 设置为使用 SSH,这样我就不必在每次与 GitHub 交互时都输入我的用户名和密码。我也不希望 IntelliJ 为我保存我的密码,因为我不确定那样的安全性。
到目前为止我最接近的是我需要编辑我的 ~/.ssh/config 文件以告诉 IntelliJ 它可以使用一个 SSH key 。不幸的是,我还没有设法找到一个有效的例子。
这是我对 ~/.ssh/config 条目的最新尝试:
Host IntelliJ
HostName github.com
User git
IdentityFile "/Users/peter/.ssh/github_rsa"
TCPKeepAlive yes
IdentitiesOnly yes
我尝试在添加该条目后重新启动 IntelliJ,但无济于事。 我在 Mac OSX 10.8.5 上运行 IntelliJ Ultimate 12.1.6
最佳答案
IntelliJ 的 GitHub 插件可让您保存密码,因此您不必每次都输入。
带键
(改编自 Multiple SSH Keys settings for different github account,感谢 CrazyCoder 评论):
创建ssh key 对
$ ssh-keygen -t rsa -C "activehacker@youremail.com"
添加 key
$ ~/.ssh/id_rsa_activehacker
确认 key 已添加
$ ssh-add -l
修改~/.ssh/config
Host github.com-activehacker HostName github.com User git IdentityFile ~/.ssh/id_rsa_activehacker
在 IntelliJ 中
VCS > 从版本控制 check out > Git
测试
如您所见,您仍然需要在每次 IntelliJ 重新启动后为 key 对输入密码(我相信密码保留在内存中)或让 IntelliJ 永久存储它。
关于macos - 如何使用 SSH 将 IntelliJ 连接到 GitHub,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20632511/