106

I've installed EGit plugin at Eclipse Helios and I'm trying to use it with my GitHub account, but when I try to configure it I get an "Auth Failed" error.

I'd been googling it but no luck... it seems to be a problem with my passphrase but AFAIK EGit is looking at the right place (/home/user/.ssh/id_rsa) and I've no problem in connect by ssh or git console client.

Some blogs says that is a problem with the URI and the Egit's parser but I still haven't found a solution.

gnat
  • 6,213
  • 108
  • 53
  • 73
tehsis
  • 1,602
  • 2
  • 11
  • 15
  • possible duplicate of [EGit - SSH Fails at Passphrase (when connecting to GitHub)](http://stackoverflow.com/questions/6316014/egit-ssh-fails-at-passphrase-when-connecting-to-github) – John Conde Jun 24 '12 at 05:20

23 Answers23

152

My answer may be outdated but hopefully it can be useful for someone.

  1. In your Eclipse go to Window > Preferences > General > Network Connections > SSH2 (or just type "SSH2" in preferences window filter box).

  2. In "Key Management" tab press "Generate RSA Key..." button. Optionally you can add comment (usually e-mail address) and passphrase to your key. Passphrase will be used during authentication on GitHub.

  3. Copy your generated public key (in a box just below "Generate RSA Key..." button) and add it to your GitHub account.
  4. Press "Save Private Key..." button to save your private RSA key into file. By default keys are stored in SSH2 home directory (see "General" tab).

That's it! Now you should be able to push your code to GitHub repo.

Andrei Petrenko
  • 3,922
  • 3
  • 31
  • 53
  • 2
    My private key didn't have the standard name (id_rsa), so it wasn't being recognized as such. I added it manually, in the preferences windows pointed by you, and it worked fine. – muriloq Jul 22 '11 at 23:21
  • I was having a similar issue, this solution worked like a charm – rjacks Oct 16 '11 at 01:22
  • 19
    I noticed that after setting up the SSH key as you describe I should not be changing the username/password in the authentication box (I was putting my GitHub credentials). The default in this box is username:git and password is blank. – harschware Feb 08 '12 at 04:05
  • I upvote thee for the right answer. We are using both personal githubs and a local gitorious server I installed at my company. We had trouble with Eclipse even though the local git was working fine. – Gepsens Feb 29 '12 at 15:17
  • 1
    This worked for me with a BitBucket git repository, I did have to restart Eclipse though. – artlung Sep 12 '13 at 23:38
  • 8
    leaving the username as git and password blank finally worked for me. – Mike R Mar 26 '14 at 21:58
  • 4
    Here is the process to add generated RSA key to your github account 1)login to your github account 2)goto settings 3)on left side you will find SSH keys,click it 4)then click add SSH keys (now paste the SSH key which you generated) – rajeev Aug 27 '14 at 06:03
  • This might be stupid but I tried generating private key, removing username, still did not work. Finally the protocol I changed from ssh to git(In the git clone dialog box). Then it worked! – Sachin C Nambiar Feb 07 '19 at 04:49
  • Although not directly relating to this, let me put a comment here (detailing my experience). I use babun (a cygwin distro) ssh-keygen. The generated key, when "cat", from command line, cannot be imported into eclipse and domino datalab. When opened the public key in an editor (notepad++ etc) and removing the line-feeds, we can import it to domino datalab but not to eclipse. – Edward Aung Apr 14 '19 at 23:17
28

I had exactly same problem but I found the cure from a Eclipse bug report!

An environment variable named GIT_SSH must be set with a path to a ssh executable [1].

For example on Ubuntu Linux (10.10 64bit):

> export GIT_SSH=/usr/bin/ssh
> eclipse

After that pushes to GitHub repository work like they should. I tested this with Eclipse Galileo and Indigo.

The problem is really annoying and the solution is far from nice. For now, making the solution permanent for, at least Ubuntu users, one must make the env variable permanent. It can be done by adding the export command to ~/.profile or ~/.bashrc [2]. For example:

> cd ~
> echo "export GIT_SSH=/usr/bin/ssh" >> .profile

And then restart Eclipse to take effect.

Sources:

caiguanhao
  • 444
  • 1
  • 4
  • 12
Akseli Palén
  • 27,244
  • 10
  • 65
  • 75
  • I've been on this problem all week - Eclipse under osx connecting to GitHub or Asssembla. Your fix works for me. Thanks. – ianmayo Oct 07 '11 at 10:57
  • On Windows, openssh didn't work for me. I had to use plink. See my answer. – Piotr Dobrogost Jan 16 '12 at 18:25
  • And it's getting closer to a released fix. At the end of the bug report someone showed how to manually download the latest jsch jar file and manually install it to make it work that way. I'm just going to go with this env var solution and wait for the that jsch jar file to get into the actually eclipse release. – crowmagnumb Apr 24 '12 at 16:30
  • OMG. Problems like this makes me wonder why Android used Eclipse in the first place. Thanks very much for your tip. That solved my problem, and EGit/Eclipse was utterly unhelpful with "Auth Fail" – Calyth Aug 18 '14 at 16:52
  • Furthermore, this worked in my configuration in which I don't have any keys stored on the machine where I run Eclipse. I keep my keys unlocked with an agent locally, and I use 'ssh -A' to launch eclipse remotely. – tbc0 Jul 06 '15 at 19:35
  • Wow, this was a problem in 2012 and STILL is a problem today. Running git clone from command line always worked, but I had to add the environment variable above to get it to work through Eclipse. Ubuntu 14.04 with Mars. – Tony Maro Jan 26 '16 at 21:02
  • It also solved a problem where jgitflow maven plugin wouldn't read the .ssh/config. With this environment set it works. Many thanks – Julien Jun 30 '16 at 13:30
16

I resolved it by selecting http as the protocol and giving my GitHub username and password.

Andrei Petrenko
  • 3,922
  • 3
  • 31
  • 53
hari_sree
  • 1,508
  • 3
  • 12
  • 24
9

After spending hours looking for the solution to this problem, I finally struck gold by making the changes mentioned on an Eclipse Forum.

Steps:

Prerequisites: mysysgit is installed with default configuration.

1.Create the file C:/Users/Username/.ssh/config (Replace "Username" with your Windows 7 user name. (e.g. C:/Users/John/.ssh/config)) and put this in it:

Host github.com
HostName github.com
User git
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa

2.Try setting up the remote repository now in Eclipse.

Cheers. It should work perfectly.

Rushal A
  • 109
  • 1
  • 4
8

You need to install msysgit, after installing you need to open Git Bash and enter there these commands:

$ git config --global user.name "Gennadiy Zlobin" (your name)
$ git config --global user.email gennad.zlobin@gmail.com (your email)
$ ssh-keygen -C "gennad.zlobin@gmail.com" -t rsa (your email)

Now your generated keys are in C:\Users\username\.ssh (in Windows 7).
Next you load the content of your public key to your project on Github
In Eclipse open Window->Preferences->General->Network->SSH2 and set your ~/.ssh as SSH Home

After that go to Key Management tab and Load existing Key - set here your private key in ~/.ssh.

After that you can push your project to Github (but I set ssh protocol, not git+ssh).

J. Steen
  • 15,470
  • 15
  • 56
  • 63
gennad
  • 5,335
  • 12
  • 44
  • 47
5

I solved same problem with adding my key to ssh;

ssh-add ~/.ssh/id_rsa 

then entered the passphrase and need restart.

Awais Qarni
  • 17,492
  • 24
  • 75
  • 137
volkan
  • 209
  • 4
  • 12
4

For *nix users who are using SSH:

Make sure the username for your account on your local machine does not differ from the username for the account on the server. Apparently, eGit does not seem to be able to handle this. For example, if your username on your local machine is 'john', and the account you are using on the server is named 'git', egit simply fails to connect (for me anyways). The only work around I have found is to make sure you have identical usernames in both the local machine and the server.

Jeshurun
  • 22,940
  • 6
  • 79
  • 92
  • 1
    Any idea is this still the case? I have been banging my head on the wall for this evening. My private key is protected with a passphrase, which Eclipse/eGit never asks for. When I try to push to remote, Eclipse just spews out an error "org.eclipse.jgit.transport.CredentialItem$StringType Passphrase for .ssh id_rsa" – Vilsepi Sep 17 '13 at 19:16
3

At the link below I posted what worked for me...

http://www.eclipse.org/forums/index.php?t=msg&goto=648905&S=9bcfa96ab726d744d41a19c7fb02d723#msg_648905

2

For you who, like me, already did setup you ssh-keys but still get the errors:

Make sure you did setup a push remote. It worked for me when I got both the Cannot get remote repository refs-problems ("... Passphrase for..." and "Auth fail" in the "Push..." dialog).

Provided that you already:

  1. Setup your SSH keys with Github (Window > Preferences > General > Network Connections > SSH2)

  2. Setup your local repository (you can follow this guide for that)

  3. Created a Github repository (same guide)

... here's how you do it:

  • Go to the Git Repositories view (Window > Show View > Other > Git Repositories)
  • Expand your Repository and right click Remotes --> "Create Remote"
  • "Remote Name": origin, "Configure push": checked --> click "OK"
  • Click the "Change..." button
  • Paste your git URI and select protocol ssh --> click "Finish"
  • Now, click "Save and Push" and NOW you should get a password prompt --> enter the public key passphrase here (provided that you DID (and you should) setup a passphrase to your public key) --> click "OK"
  • Now you should get a confirmation window saying "Pushed to YourRepository - origin" --> click "OK"
  • Push to upstream, but this time use "Configured remote repository" as your Destination Git repository
  • Go get yourself a well earned cup of coffee!
Roger
  • 2,684
  • 4
  • 36
  • 51
2

My fourpenneth: my SSH keys were set up in Cygwin, at C:\cygwin\home\<user>.ssh, so I pointed SSH to this folder instead of the default (Win7) C:\Users\<user>\ssh, as per these instructions: http://wiki.eclipse.org/EGit/User_Guide/Remote#Eclipse_SSH_Configuration

and used the ssh protocol, and it works fine. Trying to use the git protocol still gives "User not supported on the git protocol", though.

drkvogel
  • 2,061
  • 24
  • 17
1

I resolved it by selecting https as the protocol and then adding my github username and password

eden
  • 1,979
  • 3
  • 16
  • 13
1

In your GIT view where you have your repositories you will see a structure such as:

  • branches
  • tags
  • references
  • remotes
  • etc...

Click on remotes, right-click on the url of the repository there and select 'Change Credentials'.

Fico
  • 619
  • 8
  • 12
1

I updated the plugin with the nightly builds: http://www.eclipse.org/egit/download/

With an update, it worked for me. (Eclipse Helios, Mac OS X)

fbrandel
  • 1,605
  • 3
  • 17
  • 18
  • It's still not working for me :( it have been upgraded two times since i post this. May be is a bug under GNU/Linux – tehsis Nov 26 '10 at 23:02
1

Have you tried to use the ssh protocol instead on git+ssh ? I've got the same problem, and that solved it, even though official documentation tells to use git+ssh

kamisama
  • 11
  • 1
1

On Windows, setting GIT_SSH to openssh that comes with msys git didn't work (Eclipse hung during commit). Setting it to TortoisePlink solved the problem (I guess original plink would work as well). The added bonus is now Eclipse uses keys stored in pageant.

Piotr Dobrogost
  • 41,292
  • 40
  • 236
  • 366
0

I was having the same issue which it seems was down to config issue. The github mac osx app had created a ssh private key called github_rsa

In your Eclipse go to Window > Preferences > Network Connections > SSH2

In the general tab you should see SSH2 home /Users/<you username>/.ssh you'll probably see id_dsa,id_rsa defined as private keys.

Click 'Add private key' and select github_rsa located /Users/<you username>/.ssh

scottyab
  • 23,621
  • 16
  • 94
  • 105
0

IF YOU HAVE PEM FILE: In Eclipse go to Window > Preferences > Network Connections > SSH2, and then add path to your PEM file to "Private keys" and that should solve the problem.

msamadi
  • 21
  • 3
0

I wanted to make public once me too a google code fix and got the same error. Started with This video, but at Save and publish got an error. I have seen there are several question regarding to this. Some are Windows users, those are the most lucky, because usually no problems with permissions and some are Linux users.

I have a mac for mobile development use and very often meet this problems. The source for this problems is the "platform independent" solutions, which doesn't care enough for mac and they don't have access to keychain, where are stored the certificates, .pem files and so on.

All I wanted is to not make any environment settings, nor command line, just simple GUI based clicks, like a regular user.

Half part was done with Eclipse Git plugin, second part (push to Github) was done with Mac Github

Nice and easy :)

All can be done with with that native appp if I would start to learn it, I just need the push functionality from him.

Hoping it will help a mac user once.

0

I discovered that if I set up the two-step authentication in github, Eclipse isn't able to connect to Github - which makes sense because the two-step authentication in github requires you to input a number from an SMS (and Eclipse wouldn't have this information).

If this is your scenario, you might consider de-activating your two-step authentication in github, and see if that helps.

kevlaria
  • 33
  • 5
0

For existing ssh keys, I think that it's a bug in Eclipse Juno 3.8.

What I did:

1) Load the existing key by going to: Window > Preferences > "Search ssh" > Key Management Tab > Load Existing Key > Select the private key which you already have

2) Save that key by clicking the button Save Private Key. Let's name it id_dsa_github

3) Now check if push and pull are working or not. It should be.

4) Now in the general tab, remove the private key id_dsa_github and add your previous private key by clicking the button Add private key

Now you are good to go. It's taking at least one time to do all the things from EGit to register, I guess.

soham
  • 1,508
  • 6
  • 30
  • 47
0

I run into the same issue.

I thought it's something to do with my credentials and authentication.

Then finally I realised it's the URI I configured is not HTTP variant.

I was trying to push to SSH URI of my Git with HTTP configuration.

Check your URL in

Git Perspective > Remotes > Origin > Configure Fetch > Change > Make sure the prtocal is HTTPS and the URL is https version.

MohanRaj
  • 662
  • 1
  • 6
  • 21
0

I could use console to push/pull the repositories, but no in eclipse. In my case, eclipse seems can't read my SSH private key, my key started with:

-----BEGIN OPENSSH PRIVATE KEY-----

And I noticed my colleague's key started with:

-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED

I think currently eclipse can't take this new kind of key (OPENSSH PRIVATE KEY).

I solved it by: Regenerate your ssh key by using command:

ssh-keygen -m PEM -t rsa -b 2048

This will use the old way to generate the key: so it will starts with the headers:

-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED

see more information on:

https://github.com/duplicati/duplicati/issues/3360

Then you can load the key again in eclilpse by using Preferences -> Network connections -> SSH2, click "Add Private Key" (still select your private key, even you already see the name in the list of private keys, because eclipse has to reload it)

Angia
  • 177
  • 2
  • 4
0

I found a post on the Eclipse forums that solved this problem for me.

Awais Qarni
  • 17,492
  • 24
  • 75
  • 137
Daniel Jonsson
  • 3,261
  • 5
  • 45
  • 66