Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EGit / JGit » Could not connect to SSH agent via socket(Cannot connect to Github repo using Egit SSH on Linux)
Could not connect to SSH agent via socket [message #1855333] Sun, 09 October 2022 07:23 Go to next message
Benoit Blancard is currently offline Benoit BlancardFriend
Messages: 3
Registered: October 2022
Junior Member
I'm trying to use Eclipse (2022-09 version) Egit (6.3.0.202209071007-r) to clone a Github repo using ssh under Linux Mint. When I do, I get an eclipse error message :

DefaultAuthFuture[ssh-connection]: Failed (IOException) to execute: Could not connect to SSH agent via socket '/run/user/1000/keyring/ssh'



I'm using a specific rsa private key (not the default id_rsa) and it is registered with Github. I also created a .ssh/config file to specify the right identity.
Host github
    Hostname github.com
    IdentityFile ~/.ssh/chevalrouge-info
    User git


When cloning the repo with the git command line, it works. I can import the repo in Eclipse but I can't push either from eclipse.
In the Eclipse preferences, in SSH2 menu, I have set the identify in private keys field. I also see that I don't have any ssh_agent in the SSH Agent tab. But I can't add anything.

Any idea?
Re: Could not connect to SSH agent via socket [message #1855340 is a reply to message #1855333] Sun, 09 October 2022 16:49 Go to previous messageGo to next message
Thomas Wolf is currently offline Thomas WolfFriend
Messages: 576
Registered: August 2016
Senior Member
Apparently environment variable SSH_AUTH_SOCK is set but EGit cannot talk to your SSH agent (gnome-keyring?). Are there any log entries in the Eclipse log (in your workspace, under .metadata)?

When this occurs, can you double-check what "echo $SSH_AUTH_SOCK" gives, and whether gnome-keyring is running? It may have stopped, or have been restarted while Eclipse was running.

As a quick fix, add "IdentityAgent none" in your ~/.ssh/config host entry.
Re: Could not connect to SSH agent via socket [message #1855341 is a reply to message #1855340] Sun, 09 October 2022 17:26 Go to previous messageGo to next message
Benoit Blancard is currently offline Benoit BlancardFriend
Messages: 3
Registered: October 2022
Junior Member
Hi,

Yes, I believe it's linked to the SSH_AUTH_SOCK but I can't figure what the problem is.
When I start my computer, that's what I have :
$ ps -eaf | grep ssh
benblan      1486    1416  0 19:04 ?        00:00:00 /usr/bin/ssh-agent /usr/bin/im-launch cinnamon-session-cinnamon

echo ${SSH_AUTH_SOCK}
/run/user/1000/keyring/ssh


In eclipse .log, I have a complete stack of exception. I put the last ones :
Caused by: org.apache.sshd.common.SshException: DefaultAuthFuture[ssh-connection]: Failed (IOException) to execute: Could not connect to SSH agent via socket '/run/user/1000/keyring/ssh'
        at org.apache.sshd.common.future.AbstractSshFuture.lambda$verifyResult$1(AbstractSshFuture.java:131)
        at org.apache.sshd.common.future.AbstractSshFuture.formatExceptionMessage(AbstractSshFuture.java:185)
        at org.apache.sshd.common.future.AbstractSshFuture.verifyResult(AbstractSshFuture.java:130)
        at org.apache.sshd.client.future.DefaultAuthFuture.verify(DefaultAuthFuture.java:39)
        at org.apache.sshd.client.future.DefaultAuthFuture.verify(DefaultAuthFuture.java:32)
        at org.apache.sshd.common.future.VerifiableFuture.verify(VerifiableFuture.java:68)
        at org.eclipse.jgit.transport.sshd.SshdSession.connect(SshdSession.java:172)
        at org.eclipse.jgit.transport.sshd.SshdSession.connect(SshdSession.java:101)
        at org.eclipse.jgit.transport.sshd.SshdSessionFactory.getSession(SshdSessionFactory.java:256)
        ... 11 more
Caused by: com.sun.jna.LastErrorException: [2] No such file or directory
        at com.sun.jna.Native.invokeInt(Native Method)
        at com.sun.jna.Function.invoke(Function.java:426)
        at com.sun.jna.Function.invoke(Function.java:361)
        at com.sun.jna.Library$Handler.invoke(Library.java:265)
        at org.eclipse.jgit.internal.transport.sshd.agent.connector.$Proxy58.connect(Unknown Source)
        at org.eclipse.jgit.internal.transport.sshd.agent.connector.UnixDomainSocketConnector.connect(UnixDomainSocketConnector.java:123)
        at org.eclipse.jgit.internal.transport.sshd.agent.SshAgentClient.open(SshAgentClient.java:85)
        at org.eclipse.jgit.internal.transport.sshd.agent.SshAgentClient.getIdentities(SshAgentClient.java:110)
        at org.eclipse.jgit.internal.transport.sshd.JGitPublicKeyAuthentication$KeyIterator.initializeAgentIdentities(JGitPublicKeyAuthentication.java:357)
        at org.apache.sshd.client.auth.pubkey.UserAuthPublicKeyIterator.<init>(UserAuthPublicKeyIterator.java:59)
        at org.eclipse.jgit.internal.transport.sshd.JGitPublicKeyAuthentication$KeyIterator.<init>(JGitPublicKeyAuthentication.java:327)
...


I don't know if it's relevant, but if I make a ls :
ls -l /run/user/1000/keyring/
total 0
srwxrwxr-x 1 benblan benblan 0 Oct  9 19:04 control
srwxrwxr-x 1 benblan benblan 0 Oct  9 19:04 pkcs11
srwxrwxr-x 1 benblan benblan 0 Oct  9 19:04 ssh


How can you check that gnome-keyring is running?
Re: Could not connect to SSH agent via socket [message #1855343 is a reply to message #1855341] Sun, 09 October 2022 19:28 Go to previous messageGo to next message
Thomas Wolf is currently offline Thomas WolfFriend
Messages: 576
Registered: August 2016
Senior Member
I guess your /usr/bin/ssh-agent is gnome-keyring. The OpenSSH agent would use a different file name AFAIK.

The code where it fails is this.

So EGit could see the file (otherwise it would have failed on line 116), but then the socket.connect() fails. Given that the error is "No such file or directory" I wonder if the SockAddr is correct. There is some nasty stuff going on the construction of that record. It must match the C struct sockaddr_in for Unix domain sockets (AF_UNIX). Perhaps there's something special on Linux Mint, and the C library doesn't see the file name as passed from Java correctly.

I just installed Linux Mint 21 in a virtual machine, but I can't even find the correct C header file. I think it should be <netinet/in.h>. Probably I'll have to install some gcc development environment first in that Linux Mint.
Re: Could not connect to SSH agent via socket [message #1855344 is a reply to message #1855343] Sun, 09 October 2022 20:49 Go to previous messageGo to next message
Thomas Wolf is currently offline Thomas WolfFriend
Messages: 576
Registered: August 2016
Senior Member
Hm. I cannot reproduce this problem in Linux Mint 21 Cinnamon 5.4.12 (x86_64), Eclipse 2022-09, EGit 6.3.0.202209071007-r.

In my virtual machine (stock install, then a stock Eclipse download) I get
thomas@minty:~$ ps -eaf | grep keyring
thomas      1452       1  0 22:13 ?        00:00:00 /usr/bin/gnome-keyring-daemon --daemonize --login
thomas      2325    1452  0 22:23 ?        00:00:00 /usr/bin/ssh-agent -D -a /run/user/1000/keyring/.ssh
thomas      2330    2164  0 22:23 pts/0    00:00:00 grep --color=auto keyring
thomas@minty:~$ echo $SSH_AUTH_SOCK
/run/user/1000/keyring/ssh
thomas@minty:~$ ls -al /run/user/1000/keyring
total 0
drwx------  2 thomas thomas 120 Oct  9 22:23 .
drwx------ 11 thomas thomas 320 Oct  9 22:23 ..
srwxrwxr-x  1 thomas thomas   0 Oct  9 22:13 control
srwxrwxr-x  1 thomas thomas   0 Oct  9 22:13 pkcs11
srw-------  1 thomas thomas   0 Oct  9 22:23 .ssh
srwxrwxr-x  1 thomas thomas   0 Oct  9 22:13 ssh
thomas@minty:~$ 

and cloning with an SSH config like yours from Github via SSH just works fine (both with no key in the agent, using the identity file, or also with that key in the agent and the identity file moved away to ensure the agent is used).

So it's not a problem with EGit but with the setup on your machine.

I notice that my ssh-agent process is different; your command line looks different. And I notice that you don't have /run/user/1000/keyring/.ssh, so "No such file or directory" is probably even the correct error message, but apparently refers to that file... (EGit has no control over that message, it only gets back an error code but no information about which file was missing. EGit cannot improve this error message.)

It appears that the ssh-agent is started on demand by that gnome-keyring-daemon.

Since I cannot reproduce the problem, I can't help much further.

[Updated on: Sun, 09 October 2022 20:58]

Report message to a moderator

Re: Could not connect to SSH agent via socket [message #1855345 is a reply to message #1855344] Sun, 09 October 2022 21:36 Go to previous messageGo to next message
Thomas Wolf is currently offline Thomas WolfFriend
Messages: 576
Registered: August 2016
Senior Member
And hey: it would have helped a little if you had written where else you had asked for help. The French user forum was not able to help, but on stackoverflow I see that you had exactly the same problem with C git on the command line, too! But interestingly not with plain ssh.

For the command-line, the work around appears to have been export GIT_SSH_COMMAND="/usr/bin/ssh -i ~/.ssh/chevalrouge-info". That doesn't solve the problem, it just works around it because if you give a key on the command line, SSH won't even try to ask the agent.

Something is not quite right with the SSH agent setup on you machine. But as I wrote before, "IdentityAgent none" (or switching off SSH agent usage in the git preferences in Eclipse) would be the corresponding work-arounds for Eclipse.
Re: Could not connect to SSH agent via socket [message #1855453 is a reply to message #1855345] Sat, 15 October 2022 06:28 Go to previous message
Benoit Blancard is currently offline Benoit BlancardFriend
Messages: 3
Registered: October 2022
Junior Member
Hi,
Thank you very much for taking the time to help. Sorry for not saying about the other posts I made. I didn't think it would help.
For the command line problem I had, I didn't use the GIT_SSH_COMMAND. I rather created a ssh config file to specify the right identity for github. I don't think it's the same problem as with eclipse.
I think also that it has to be something with the ssh agent installation on my machine.
But finally I tried to switch off the ssh agent in Eclipse as you said, and I got it worked.
Thanks!
Previous Topic:'Checkout this version' on files in a Stash issues with new or deleted files
Next Topic:EGit ignores my attempt to stage files in one repository
Goto Forum:
  


Current Time: Sat Jul 20 19:09:28 GMT 2024

Powered by FUDForum. Page generated in 0.03723 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top