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.
Using IntelliJ 2016.3.3 this seems very straight forward by following the steps below:
- Generate your keypair to use, if none exists already with
ssh-keygen
Add the key to your github profile as per https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/
Modify the settings in IntelliJ under | VersionControl > GitHub
Tick 'Clone git repositories using ssh'
Choose 'Native' as 'SSH executable'
The answer above by kukido seems to now be out of date; the IntelliJ UI no longer provides the same level of access to the github URL. And, the default "built-in" (to IntelliJ) ssh executable seems to not respect the .ssh/config file settings. What I have found now works is to switch from using the built-in ssh executable to the "native" ssh executable. This is done by visiting Settings... | Version Control | Git
and then choosing Native
in the SSH executable
pulldown menu.
This applies to IntelliJ version 2016.2 and I'm pretty sure earlier versions such as 2016.1 and the 2015 series.
Steve Byrne is right about the changes to this procedure.
As I do not have enough reputation to comment, I would like to add to his answer that I could only make this work with Github when inputing the SSH URL in the prompt for cloning a repo. You can get your repo's SSH URL by clicking on "Clone or Download" and then "Use SSH" on Github, like so: