Site icon Automation Dojos

How To Add SSH Private Keys to Eclipse

One of the common use cases for accessing Git repositories on Github is authentication via SSH keys. This offers a secure way of working with Github repositories using SSH protocol.

If you use Eclipse IDE for development and want to use the same for Git workflows like ‘commit’, ‘pull’, ‘push’ etc. you can easily do so by installing one of the Git plugins for Eclipse for example ‘EGit’. By default Eclipse (EGit) would prompt you for username/password while doing Git workflows like ‘push’, you also have the option to save your Git credentials within Eclipse so you don’t have to provide your credentials every time.

However, if you use SSH keys for Git workflows rather than username/password, here is how you can add SSH keys to Eclipse so Eclipse does not prompt you for credentials while doing Git workflows.

Open Eclipse Preferences

Open the Eclipse Preferences via Window > Preferences

Now type in ‘SSH’ in the search box on the ‘Preferences’ window

Open General SSH2 Settings

Click on ‘SSH’ under, General > Network Connections > SSH2 and open Tab named ‘General’

Set SSH Home Location

On the SSH preferences window, check that you have correctly set your ‘SSH2 Home’ location (path).

Assuming you have local Git installation on your system, the standard path to .ssh home would usually be ‘.ssh’ folder in the user home directory e.g <userhome>/<.ssh>

In case you store your keys somewhere else other than the standard SSH home then you can specify that location as path to SSH home.

Set SSH Private Key/s

While on the SSH window, now click on the ‘Add Private Key’ button and browse to the location of your SSH private key and select your SSH key.

You can specify/load multiple SSH keys using this window separated by commas.

Click Apply to save your changes.

Set/Verify Authentication Method

Next, while on the SSH preferences window, select the tab named ‘Authentication Methods’ and make sure you select/check the ‘publickey’ option. Click Apply to save your changes.

Optional: Save SSH Key ‘Passphrase’ in Secure Store

If you have a ‘passphrase’ (password) set on your SSH key then you also have the option to save your passphrase in Secure Store using Eclipse. If you save your passphrase using this option then Eclipse would not prompt you for a passphrase while doing Git workflows.

For storing your passphrase within Eclipse Secure Store, type ‘Git’ in the search box on the ‘Preferences’ window and navigate to Version Control (Team) > Git and select (check) the option ‘Store SSH Key Passphrase in secure store’

Click Apply and Close to save your changes. DONE!

[td_smart_list_end]
Exit mobile version