如何使用SSH将IntelliJ连接到GitHub [英] How do I connect IntelliJ to GitHub using SSH
问题描述
我已成功配置我的GitHub客户端以使用SSH,并收到来自GitHub的确认电子邮件,其中添加了新的SSH密钥。我想设置IntelliJ以使用SSH,以便每次与GitHub进行交互时都不必输入用户名和密码。我也不希望IntelliJ为我保存我的密码,因为我不确定这将是多么安全。
距离我最近的是我需要编辑我的〜/ .ssh / config文件来告诉IntelliJ它有一个可以使用的SSH密钥。不幸的是,我还没有设法找到一个可行的例子。
这是我在〜/ .ssh / config条目中的最新尝试:
主机IntelliJ
HostName github.com
用户git
IdentityFile/Users/peter/.ssh/github_rsa
TCPKeepAlive yes
IdentitiesOnly yes
我已经尝试添加该条目后重新启动IntelliJ,但无济于事。
我在Mac OSX 10.8.5上运行IntelliJ Ultimate 12.1.6
IntelliJ的GitHub插件可以让你保存密码,所以你不必每次都输入密码。
使用键
(改编自针对不同github帐户的多个SSH密钥设置,感谢 CrazyCoder 评论):
-
创建ssh密钥对
$ ssh-keygen -t rsa -Cactivehacker @ youremail .com
-
添加密钥
$〜/ .ssh / id_rsa_activehacker
-
确认已添加密钥
$ ssh-add -l
-
修改〜/ .ssh / config
主机github.com -activehacker
HostName github.com
User git
IdentityFile〜/ .ssh / id_rsa_activehacker
在IntelliJ中
VCS> Checkout from版本控制> Git
测试
I have successfully configured my GitHub client to use SSH, and received the confirmatory email from GitHub that a new SSH key was added. I would like to setup IntelliJ to use SSH as well, so that I don't have to enter my Username and Password every time I interact with GitHub. I also don't want IntelliJ to save my password for me, since I am unsure how secure that would be.
The closest I have come so far is that I need to edit my ~/.ssh/config file to tell IntelliJ that there is an SSH key it can use. Unfortunately I have not managed to find an example that works.
Here is my latest attempt at a ~/.ssh/config entry:
Host IntelliJ
HostName github.com
User git
IdentityFile "/Users/peter/.ssh/github_rsa"
TCPKeepAlive yes
IdentitiesOnly yes
I have tried restarting IntelliJ after adding that entry, but to no avail. I'm running IntelliJ Ultimate 12.1.6 on Mac OSX 10.8.5
GitHub plugin for IntelliJ lets you to save the password, so you don't have to enter it every time.
With keys
(adapted from Multiple SSH Keys settings for different github account, thanks to CrazyCoder comment):
Create ssh key pair
$ ssh-keygen -t rsa -C "activehacker@youremail.com"
Add key
$ ~/.ssh/id_rsa_activehacker
Confirm that the key is added
$ ssh-add -l
Modify ~/.ssh/config
Host github.com-activehacker HostName github.com User git IdentityFile ~/.ssh/id_rsa_activehacker
In IntelliJ
VCS > Checkout from Version Control > Git
Test
As you can see, you will still have to either enter passphrase for the key pair after every IntelliJ relaunch(I believe the passphrase is kept in memory) or let IntelliJ to store it permanently.
这篇关于如何使用SSH将IntelliJ连接到GitHub的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!