Home » Eclipse Projects » EGit / JGit » Unexpected reply from ssh-agent: SSH_AGENT_FAILURE(Eclipse on Windows 10 to pull a GitHub repo using a YubiKey Hardware Ke)
Unexpected reply from ssh-agent: SSH_AGENT_FAILURE [message #1859947] |
Thu, 06 July 2023 10:48  |
Eclipse User |
|
|
|
I am trying to use Eclipse on Windows 10 to pull a GitHub repo using a YubiKey Hardware Key
I get the error "Unexpected reply from ssh-agent: SSH_AGENT_FAILURE"
Using Git from the command line to pull the repo on Windows 10 with the YubiKey works.
Using Eclipse on my Mac to pull the same repo with the YubiKey also works without error.
I have updated Eclipse to the latest version (but have had the error with older versions too).
Eclipse is:
Version: 2023-06 (4.28.0)
Build id: 20230608-1333
Git integration for Eclipse 6.6.0.202305301015-r org.eclipse.egit.feature.group Eclipse EGit
I am using the Win32 Open SSH from Microsoft. Eclipse Git Preferences are set to
Use SSH agent for SSH connections = true, and Default SSH agent = "Win32 OpenSSH". The ssh-agent is running.
I have found "SSH_AGENT_FAILURE" in the OpenSSH source code, so the error suggest to me that JGIT has successfully connected to the ssh-agent
The Stacktrace is:
org.eclipse.jgit.api.errors.TransportException: git@github.ibm.com:OTMS/current.git: Unexpected reply from ssh-agent: SSH_AGENT_FAILURE
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:249)
at org.eclipse.jgit.api.PullCommand.call(PullCommand.java:266)
at org.eclipse.egit.core.op.PullOperation$PullJob.run(PullOperation.java:256)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.eclipse.jgit.errors.TransportException: git@github.ibm.com:OTMS/current.git: Unexpected reply from ssh-agent: SSH_AGENT_FAILURE
at org.eclipse.jgit.transport.sshd.SshdSessionFactory.getSession(SshdSessionFactory.java:263)
at org.eclipse.jgit.transport.sshd.SshdSessionFactory.getSession(SshdSessionFactory.java:1)
at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:107)
at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:281)
at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:153)
at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:153)
at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:105)
at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1462)
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:238)
... 3 more
Caused by: org.apache.sshd.common.SshException: Unexpected reply from ssh-agent: SSH_AGENT_FAILURE
at org.apache.sshd.common.future.AbstractSshFuture.verifyResult(AbstractSshFuture.java:141)
at org.apache.sshd.client.future.DefaultAuthFuture.verify(DefaultAuthFuture.java:56)
at org.apache.sshd.client.future.DefaultAuthFuture.verify(DefaultAuthFuture.java:35)
at org.apache.sshd.common.future.VerifiableFuture.verify(VerifiableFuture.java:74)
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: org.apache.sshd.common.SshException: Unexpected reply from ssh-agent: SSH_AGENT_FAILURE
at org.eclipse.jgit.internal.transport.sshd.agent.SshAgentClient.sign(SshAgentClient.java:211)
at org.apache.sshd.client.auth.pubkey.KeyAgentIdentity.sign(KeyAgentIdentity.java:63)
at org.apache.sshd.client.auth.pubkey.UserAuthPublicKey.appendSignature(UserAuthPublicKey.java:446)
at org.apache.sshd.client.auth.pubkey.UserAuthPublicKey.processAuthDataRequest(UserAuthPublicKey.java:413)
at org.apache.sshd.client.auth.AbstractUserAuth.process(AbstractUserAuth.java:88)
at org.apache.sshd.client.session.ClientUserAuthService.processUserAuth(ClientUserAuthService.java:345)
at org.apache.sshd.client.session.ClientUserAuthService.process(ClientUserAuthService.java:267)
at org.apache.sshd.common.session.helpers.CurrentService.process(CurrentService.java:109)
at org.apache.sshd.common.session.helpers.AbstractSession.doHandleMessage(AbstractSession.java:592)
at org.apache.sshd.common.session.helpers.AbstractSession.lambda$handleMessage$0(AbstractSession.java:523)
at org.apache.sshd.common.util.threads.ThreadUtils.runAsInternal(ThreadUtils.java:68)
at org.apache.sshd.common.session.helpers.AbstractSession.handleMessage(AbstractSession.java:522)
at org.apache.sshd.common.session.helpers.AbstractSession.decode(AbstractSession.java:1649)
at org.apache.sshd.common.session.helpers.AbstractSession.messageReceived(AbstractSession.java:483)
at org.eclipse.jgit.internal.transport.sshd.JGitClientSession.messageReceived(JGitClientSession.java:197)
at org.apache.sshd.common.session.helpers.AbstractSessionIoHandler.messageReceived(AbstractSessionIoHandler.java:64)
at org.apache.sshd.common.io.nio2.Nio2Session.handleReadCycleCompletion(Nio2Session.java:407)
at org.apache.sshd.common.io.nio2.Nio2Session$1.onCompleted(Nio2Session.java:380)
at org.apache.sshd.common.io.nio2.Nio2Session$1.onCompleted(Nio2Session.java:375)
at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.lambda$completed$0(Nio2CompletionHandler.java:38)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.completed(Nio2CompletionHandler.java:37)
at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:129)
at java.base/sun.nio.ch.Invoker$2.run(Invoker.java:221)
at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:113)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
|
|
| | |
Re: Unexpected reply from ssh-agent: SSH_AGENT_FAILURE [message #1859978 is a reply to message #1859958] |
Fri, 07 July 2023 11:06   |
Eclipse User |
|
|
|
I think I have got Eclipse / JGIT working on Windows after hours of experimentation.
The preconditions seem to be:
a) Pageant (Putty SSH Agent) is NOT running: kill with Task Manger if running.
b) SSH_AUTH_SOCK is NOT set: Unset in env vars (e.g on reboot it is set by "something" for the pageant pipe"). This is even more important than a) above.
c) OpenSSH Authentication Agent service is running. (I am currently using v9.2.2.0 from https://github.com/PowerShell/Win32-OpenSSH, not the OpenSSH from Microsoft (Apps and Features / Optional Features),
d) YubiKey Hardware Key is inserted.
e) Eclipse / JGIt "Use SSH Agent for SSH Connections" = true, Default SSH_Agent = "Win32 OpenSSH",
Once all of that is checked and double-checked:
1) open a NEW cmd shell. Double check that SSH_AUTH_SOCK is not set for that session (for an old shell it may still be set....).
2) Ssh-add -L -> "The agent has no identities": Any other response / error implies one or more of the preconditions above are not met.
3) From Eclipse / JGIT, git pull -> pull fails "publicly: no keys to try": This is "OK" because the agent has no identities loaded.
4) ssh-add -s "C:\Program Files\Yubico\Yubico PIV Tool\bin\libykcs11.dll" -> Enter Passphrase for PKCS#11" -> Card Added ..
5) ssh-add -L -> lists two sh-rsa keys
6) From Eclipse / JGIT, git pull -> pull is successful!!!!
If I perform similar tests with Git from the command line, at step 3) Git will prompt me for the Yubikey pin, and will succeed. i.e. I don't need to run step 4). But if I do run step 4, I no longer need to enter the pin.
Later this evening I will revert to the OpenSSH from Microsoft, to see if that caused the problem initially reported.
[Updated on: Fri, 07 July 2023 13:41] by Moderator
|
|
| | |
Re: Unexpected reply from ssh-agent: SSH_AGENT_FAILURE [message #1859985 is a reply to message #1859984] |
Fri, 07 July 2023 15:10   |
Eclipse User |
|
|
|
After a brief look into the OpenSSH code, it appears that SSH will, if PKCS11Provider is set, automatically start a little helper application that behaves like an ssh-agent and that communicates with the shared library to put the smartcard key into this little special agent. That might explain why it just works with command-line git.
We have definitely not implemented this. So with JGit, the way to go in this case is indeed to manually or otherwise add the smartcard key to an existing agent via ssh-add -s, and then set up JGit to use that agent. The agent must understand the SSH_AGENTC_ADD_SMARTCARD_KEY command. Don't know whether all do.
Implementing this in JGit or in Apache MINA sshd even only in the SSH client library would be a lot of work involving loading a shared native library given by name at runtime and then communicating with that library to figure out the interface methods and then call them. And for safety reasons, that dynamic library stuff should really be in a separate process. The code in OpenSSH for doing it doesn't look exactly trivial, and via Java it might be even more complicated. Possibly doable with JNA, but non-trivial, and certainly different for Unices or for Windows.
BTW: also interesting: https://www.exploit-db.com/exploits/40963 . (Gives also some insights into how this works in OpenSSH at all.) Looking into ssh-agent.c, it appears that the agent has a whitelist of wildcard glob patterns and only loads libraries that match a whitelisted pattern.
P.S.: just as an aside: JGit doesn't do agent forwarding. If you need to hop through servers to get to the git repo, use ProxyJump instead.
[Updated on: Fri, 07 July 2023 15:13] by Moderator
|
|
| | | |
Re: Unexpected reply from ssh-agent: SSH_AGENT_FAILURE [message #1860016 is a reply to message #1860014] |
Tue, 11 July 2023 02:32   |
Eclipse User |
|
|
|
Hi Thomas
Thanks, I will look into that in the next few days (today I am "away" from my Windows laptop).
In the meantime, after more experimentation, I have discovered that the key obstacle that prevents the combination of JGIT + OpenSSH + YubiKey working is the incorrect setttng of the environment variable SSH_AUTH_SOCK.
In particular it must be correctly set in the Windows cmd session in which the OpenSSH ssh-add commands are executed. It does not matter if SSH_AUTH_SOCK is generally set to something else (e.g for Putty Pageant).
So that the ssh-add command works with OpenSSH,in the cmd session from which ssh-add is called, SSH_AUTH_SOCK must be set to either:
SET SSH_AUTH_SOCK=
or
SET SSH_AUTH_SOCK=//./pipe/openssh-ssh-agen
either are correct for OpenSSH on Windows.
Once so set:
ssh-add -s "C:\Program Files\Yubico\Yubico PIV Tool\bin\libykcs11.dll"
should work with error: i.e. prompt for the YubiKey pin
After that, the YubiKey private keys should be loaded to the OpenSSH ssh-agent, and anything properly using that, including Eclipse / JGIT, should no longer prompt for the pin.
Curiously, once the keys have been successfully loaded to the OpenSSH agent, they seem to be persisted, and are loaded even after a reboot!
|
|
| | | | | | | | | | | | |
Re: Unexpected reply from ssh-agent: SSH_AGENT_FAILURE [message #1860074 is a reply to message #1860073] |
Sat, 15 July 2023 12:57   |
Eclipse User |
|
|
|
Hi Thomas
Edit: With a bit of hacking to get around some errors, your change now works:
I am now happily debugging a Child Eclipse in which I am calling JGit to pull my repo with the YubiKey.
In the Parent Eclipse, I get this error:
[sshd-JGitSshClient[1dfee458]-nio2-thread-3] WARN org.eclipse.jgit.internal.transport.sshd.JGitPublicKeyAuthentication - HostConfig for host github.ibm.com (hostname github.ibm.com): could not instantiate PKCS11Provider C:\Program Files\Yubico\Yubico PIV Tool\bin\libykcs11.dll
java.security.InvalidParameterException: Error configuring SunPKCS11 provider
at jdk.crypto.cryptoki/sun.security.pkcs11.SunPKCS11.configure(SunPKCS11.java:122)
at org.eclipse.jgit.internal.transport.sshd.pkcs11.Pkcs11Provider.lambda$0(Pkcs11Provider.java:145)
at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1708)
at org.eclipse.jgit.internal.transport.sshd.pkcs11.Pkcs11Provider.getProvider(Pkcs11Provider.java:128)
at org.eclipse.jgit.internal.transport.sshd.JGitPublicKeyAuthentication$KeyIterator.getPkcs11Keys(JGitPublicKeyAuthentication.java:516)
at org.eclipse.jgit.internal.transport.sshd.JGitPublicKeyAuthentication$KeyIterator.getAgentIdentities(JGitPublicKeyAuthentication.java:411)
at org.eclipse.jgit.internal.transport.sshd.JGitPublicKeyAuthentication$KeyIterator.initializeAgentIdentities(JGitPublicKeyAuthentication.java:348)
at org.apache.sshd.client.auth.pubkey.UserAuthPublicKeyIterator.<init>(UserAuthPublicKeyIterator.java:59)
at org.eclipse.jgit.internal.transport.sshd.JGitPublicKeyAuthentication$KeyIterator.<init>(JGitPublicKeyAuthentication.java:320)
at org.eclipse.jgit.internal.transport.sshd.JGitPublicKeyAuthentication.createPublicKeyIterator(JGitPublicKeyAuthentication.java:139)
at org.apache.sshd.client.auth.pubkey.UserAuthPublicKey.init(UserAuthPublicKey.java:108)
at org.eclipse.jgit.internal.transport.sshd.JGitPublicKeyAuthentication.init(JGitPublicKeyAuthentication.java:125)
at org.apache.sshd.client.session.ClientUserAuthService.tryNext(ClientUserAuthService.java:410)
at org.apache.sshd.client.session.ClientUserAuthService.processUserAuth(ClientUserAuthService.java:331)
at org.apache.sshd.client.session.ClientUserAuthService.process(ClientUserAuthService.java:267)
at org.apache.sshd.common.session.helpers.CurrentService.process(CurrentService.java:109)
at org.apache.sshd.common.session.helpers.AbstractSession.doHandleMessage(AbstractSession.java:592)
at org.apache.sshd.common.session.helpers.AbstractSession.lambda$handleMessage$0(AbstractSession.java:523)
at org.apache.sshd.common.util.threads.ThreadUtils.runAsInternal(ThreadUtils.java:68)
at org.apache.sshd.common.session.helpers.AbstractSession.handleMessage(AbstractSession.java:522)
at org.apache.sshd.common.session.helpers.AbstractSession.decode(AbstractSession.java:1649)
at org.apache.sshd.common.session.helpers.AbstractSession.messageReceived(AbstractSession.java:483)
at org.eclipse.jgit.internal.transport.sshd.JGitClientSession.messageReceived(JGitClientSession.java:208)
at org.apache.sshd.common.session.helpers.AbstractSessionIoHandler.messageReceived(AbstractSessionIoHandler.java:64)
at org.apache.sshd.common.io.nio2.Nio2Session.handleReadCycleCompletion(Nio2Session.java:407)
at org.apache.sshd.common.io.nio2.Nio2Session$1.onCompleted(Nio2Session.java:380)
at org.apache.sshd.common.io.nio2.Nio2Session$1.onCompleted(Nio2Session.java:375)
at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.lambda$completed$0(Nio2CompletionHandler.java:38)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.completed(Nio2CompletionHandler.java:37)
at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:129)
at java.base/sun.nio.ch.Invoker$2.run(Invoker.java:221)
at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:113)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: sun.security.pkcs11.ConfigurationException: Unknown keyword 'Files\Yubico\Yubico', line 1
at jdk.crypto.cryptoki/sun.security.pkcs11.Config.parse(Config.java:499)
at jdk.crypto.cryptoki/sun.security.pkcs11.Config.<init>(Config.java:221)
at jdk.crypto.cryptoki/sun.security.pkcs11.SunPKCS11$1.run(SunPKCS11.java:118)
at jdk.crypto.cryptoki/sun.security.pkcs11.SunPKCS11$1.run(SunPKCS11.java:115)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:569)
at jdk.crypto.cryptoki/sun.security.pkcs11.SunPKCS11.configure(SunPKCS11.java:115)
... 35 more
The file that is being parsed has this content
name = JGit-0-C:\Program Files\Yubico\Yubico PIV Tool\bin\libykcs11.dll
library = C:\Program Files\Yubico\Yubico PIV Tool\bin\libykcs11.dll
slotListIndex = 0
I think paths with spaces are not being properly handled, hence the 'Files\Yubico\Yubico' reported in the error.
If I move the Yubico Dlls to a path with no spaces, and update the .ssh/config accordingly, then it works! I get a popup dialog requesting the Yubikey passphrase, and the Git pull succeeds.
On a second pull, I am not prompted again for the passphrase.
Curiously, ssh-add -L on the command line reports "The agent has no identities."
[Updated on: Sat, 15 July 2023 13:32] by Moderator
|
|
| |
Re: Unexpected reply from ssh-agent: SSH_AGENT_FAILURE [message #1860076 is a reply to message #1860075] |
Sat, 15 July 2023 17:00   |
Eclipse User |
|
|
|
Hoi Thomas
I agree, it is great that we have proved the basic mechanism works, at least on Windows.
Some thoughts at this stage are:
1) The problem with spaces is probably a minor issue, easily resolved. However this error seems to have been swallowed, and not re-thrown. I only caught it in the parent Eclipse instance. Had it been thrown to the child instance, we might have understood this error without debugging.
2) Having understood the "path with spaces problem*, I copied the YubiKey Dlls to a directory without spaces. Unfortunately, in my excitement, I made a typo (i.e. the entry in .ssh/config was not quite correct).. Similar to 1) above, this error was only reported in the parent Eclipse instance.
3) There is potential for confusion between "slot" and "slot index*. Using the YubiKey PIV, the Authentication key is stored in slot 9a. However the slotListIndex must be "0". Cleverly worded documentation should help clarify this.
I thank you for both your quick responses, and for your clear instructions. Only a few days ago I could not have imagined how easy it is to debug a child Eclipse instance. Once one knows how, it is child's play.
I have started installing a similar Eclipse / Jgit dbug setup on macOS. Hopefully that should be equally helpful on that OS.
mfg und bis bald,
Chris
[Updated on: Sat, 15 July 2023 17:01] by Moderator
|
|
|
Re: Unexpected reply from ssh-agent: SSH_AGENT_FAILURE [message #1860077 is a reply to message #1860075] |
Sat, 15 July 2023 17:31   |
Eclipse User |
|
|
|
Yes, slot ID and slot list index are different things. "9a" would be the slot ID (and it's an unsigned long, just shown in hex). This ID may not be static; it may change when the token is removed and re-inserted, or possibly also when the library is loaded again. (Some libraries may provide stable slot IDs, though.) The slot list index is always an integer, and the index of the first slot is always zero. (Though I don't know what the "first" slot is if you have two YubiKeys plugged in. The one inserted first?)
Unfortunately the Java SunPKCS11 provider is rather limited in its ways to select a token. It can be done via slot ID or slot list index only, and the latter appears to be preferred. I see nothing to select a slot by token manufacturer or serial number or the like.
That the agent still reports it had no identities is expected. The YubiKey identity is not cached in the agent, it is cached in the YubiKey library. There is no agent involved at all in all this. As long as Eclipse runs, and the YubiKey is not removed, you should be prompted only once for the PIN. When the token is removed and re-inserted, you might be asked (in fact, should be asked) once again for the PIN.
JGit also ignores AddKeysToAgent for PKCS11Provider keys. With built-in PKCS11 support, that is not needed at all in JGit. It would make sense only for agent forwarding, but JGit doesn't do that anyway. If you have to hop through servers to get to the repository, use ProxyJump instead.
Anyway, the real problem was the name containing spaces, and indeed the Java SunPKCS11 provider has trouble with paths containing multiple successive spaces.
https://ci.eclipse.org/jgit/job/stable/job/jgit.gerrit-pipeline.java11/4098/artifact/ has fixes for that and should work also with library paths that contain spaces.
|
|
| | | |
Re: Unexpected reply from ssh-agent: SSH_AGENT_FAILURE [message #1860139 is a reply to message #1860107] |
Wed, 19 July 2023 07:48   |
Eclipse User |
|
|
|
Hi Thomas
Some more testing:
If I try to do a SSH from the commandline, on both the Mac and Windows I get the error
/Users/christopherlamb/.ssh/config: line 20: Bad configuration option: pkcs11slotlistindex
/Users/christopherlamb/.ssh/config: terminating, 1 bad configuration options
It looks like ssh is objecting to the key "pkcs11slotlistindex". Is that still used in the latest code? I think you said it would be temporary.
As promised I set up an Eclipse / JGIT debug setup on my Mac as well, with patch 4103.
This got as far as popping the dialog requesting the YubiKey passphrase / pin, but then failed with this error "Secure storage was unable to retrieve the master password from the OS keyring. Make sure that this application has access to the OS keyring". (full stack a the end of this mail"
I suspect that the error is an Apple security thing ... down to quaranting or signing ...
Pulling 1 repository
git@github.ibm.com:OTMS/w21.7.git: [ssh-connection]: Failed (ProviderException) to execute: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DEVICE_ERROR
git@github.ibm.com:OTMS/w21.7.git: [ssh-connection]: Failed (ProviderException) to execute: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DEVICE_ERROR
WARNING: Using incubator modules: jdk.incubator.foreign, jdk.incubator.vector
2023-07-16 15:53:47.946 java[34836:577917] +[CATransaction synchronize] called within transaction
2023-07-16 15:58:12.303 java[34836:577917] +[CATransaction synchronize] called within transaction
2023-07-16 15:58:12.462 java[34836:577917] +[CATransaction synchronize] called within transaction
2023-07-16 16:01:03.210 java[34836:577917] +[CATransaction synchronize] called within transaction
[Worker-26: Pulling origin from git@github.ibm.com:OTMS/w21.7.git] INFO org.apache.sshd.common.util.security.eddsa.EdDSASecurityProviderRegistrar - getOrCreateProvider(EdDSA) created instance of net.i2p.crypto.eddsa.EdDSASecurityProvider
[Worker-26: Pulling origin from git@github.ibm.com:OTMS/w21.7.git] INFO org.apache.sshd.common.io.DefaultIoServiceFactoryFactory - No detected/configured IoServiceFactoryFactory; using Nio2ServiceFactoryFactory
!SESSION 2023-07-16 15:51:31.458 -----------------------------------------------
eclipse.buildId=unknown
java.version=17.0.7
java.vendor=Azul Systems, Inc.
BootLoader constants: OS=macosx, ARCH=x86_64, WS=cocoa, NL=en_GB
Framework arguments: -product org.eclipse.sdk.ide
Command-line arguments: -product org.eclipse.sdk.ide -data /Users/christopherlamb/Projects/OTMS/tools/eclipse/eclipse4jgit/egit-master/ws/../JGitDebugChildEclipseWorkspace -dev file:/Users/christopherlamb/Projects/OTMS/tools/eclipse/eclipse4jgit/egit-master/ws/.metadata/.plugins/org.eclipse.pde.core/JGit Debug Child Eclipse/dev.properties -os macosx -ws cocoa -arch x86_64 -consoleLog
!ENTRY org.eclipse.equinox.security 4 0 2023-07-16 16:05:47.317
!MESSAGE Secure storage was unable to retrieve the master password from the OS keyring. Make sure that this application has access to the OS keyring. If the error persists, the password recovery feature could be used, or secure storage can be deleted and re-created.
!STACK 0
java.lang.SecurityException: Could not obtain password. Result: -25300
at org.eclipse.equinox.internal.security.osx.OSXProvider.getPassword(Native Method)
at org.eclipse.equinox.internal.security.osx.OSXProvider.getPassword(OSXProvider.java:49)
at org.eclipse.equinox.internal.security.storage.PasswordProviderModuleExt.getPassword(PasswordProviderModuleExt.java:44)
at org.eclipse.equinox.internal.security.storage.SecurePreferencesRoot.getModulePassword(SecurePreferencesRoot.java:259)
at org.eclipse.equinox.internal.security.storage.SecurePreferencesRoot.getPassword(SecurePreferencesRoot.java:220)
at org.eclipse.equinox.internal.security.storage.SecurePreferences.put(SecurePreferences.java:229)
at org.eclipse.equinox.internal.security.storage.SecurePreferencesWrapper.put(SecurePreferencesWrapper.java:128)
at org.eclipse.egit.core.internal.credentials.EGitSecureStore.putCredentials(EGitSecureStore.java:76)
at org.eclipse.egit.core.internal.EGitSshdSessionFactory$EGitFilePasswordProvider.keyLoaded(EGitSshdSessionFactory.java:294)
at org.eclipse.jgit.transport.sshd.IdentityPasswordProvider.keyLoaded(IdentityPasswordProvider.java:286)
at org.eclipse.jgit.internal.transport.sshd.pkcs11.SecurityCallback.passwordTried(SecurityCallback.java:113)
at org.eclipse.jgit.internal.transport.sshd.pkcs11.Pkcs11Provider.load(Pkcs11Provider.java:218)
at org.eclipse.jgit.internal.transport.sshd.pkcs11.Pkcs11Provider.getKeys(Pkcs11Provider.java:295)
at org.eclipse.jgit.internal.transport.sshd.JGitPublicKeyAuthentication$KeyIterator.getPkcs11Keys(JGitPublicKeyAuthentication.java:515)
at org.eclipse.jgit.internal.transport.sshd.JGitPublicKeyAuthentication$KeyIterator.getAgentIdentities(JGitPublicKeyAuthentication.java:410)
at org.eclipse.jgit.internal.transport.sshd.JGitPublicKeyAuthentication$KeyIterator.initializeAgentIdentities(JGitPublicKeyAuthentication.java:348)
at org.apache.sshd.client.auth.pubkey.UserAuthPublicKeyIterator.<init>(UserAuthPublicKeyIterator.java:59)
at org.eclipse.jgit.internal.transport.sshd.JGitPublicKeyAuthentication$KeyIterator.<init>(JGitPublicKeyAuthentication.java:320)
at org.eclipse.jgit.internal.transport.sshd.JGitPublicKeyAuthentication.createPublicKeyIterator(JGitPublicKeyAuthentication.java:139)
at org.apache.sshd.client.auth.pubkey.UserAuthPublicKey.init(UserAuthPublicKey.java:108)
at org.eclipse.jgit.internal.transport.sshd.JGitPublicKeyAuthentication.init(JGitPublicKeyAuthentication.java:125)
at org.apache.sshd.client.session.ClientUserAuthService.tryNext(ClientUserAuthService.java:410)
at org.apache.sshd.client.session.ClientUserAuthService.processUserAuth(ClientUserAuthService.java:331)
at org.apache.sshd.client.session.ClientUserAuthService.process(ClientUserAuthService.java:267)
at org.apache.sshd.common.session.helpers.CurrentService.process(CurrentService.java:109)
at org.apache.sshd.common.session.helpers.AbstractSession.doHandleMessage(AbstractSession.java:592)
at org.apache.sshd.common.session.helpers.AbstractSession.lambda$handleMessage$0(AbstractSession.java:523)
at org.apache.sshd.common.util.threads.ThreadUtils.runAsInternal(ThreadUtils.java:68)
at org.apache.sshd.common.session.helpers.AbstractSession.handleMessage(AbstractSession.java:522)
at org.apache.sshd.common.session.helpers.AbstractSession.decode(AbstractSession.java:1649)
at org.apache.sshd.common.session.helpers.AbstractSession.messageReceived(AbstractSession.java:483)
at org.eclipse.jgit.internal.transport.sshd.JGitClientSession.messageReceived(JGitClientSession.java:208)
at org.apache.sshd.common.session.helpers.AbstractSessionIoHandler.messageReceived(AbstractSessionIoHandler.java:64)
at org.apache.sshd.common.io.nio2.Nio2Session.handleReadCycleCompletion(Nio2Session.java:407)
at org.apache.sshd.common.io.nio2.Nio2Session$1.onCompleted(Nio2Session.java:380)
at org.apache.sshd.common.io.nio2.Nio2Session$1.onCompleted(Nio2Session.java:375)
at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.lambda$completed$0(Nio2CompletionHandler.java:38)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.completed(Nio2CompletionHandler.java:37)
at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:129)
at java.base/sun.nio.ch.Invoker$2.run(Invoker.java:221)
at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:113)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
[sshd-JGitSshClient[5acd91bb]-nio2-thread-7] WARN org.eclipse.jgit.internal.transport.sshd.JGitPublicKeyAuthentication - processAuthDataRequest(JGitClientSession[git@github.ibm.com/169.60.70.162:22])[ssh-connection][publickey] sent algorithm rsa-sha2-512 but got back ssh-rsa from SSH-2.0-babeld-9e792ef
[sshd-JGitSshClient[5acd91bb]-nio2-thread-7] WARN org.eclipse.jgit.internal.transport.sshd.JGitClientSession - exceptionCaught(JGitClientSession[git@github.ibm.com/169.60.70.162:22])[state=Opened] ProviderException: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DEVICE_ERROR
!ENTRY org.eclipse.egit.core 4 0 2023-07-16 16:05:47.547
!MESSAGE Pulling 1 repository
!SUBENTRY 1 org.eclipse.egit.core 4 0 2023-07-16 16:05:47.547
!MESSAGE git@github.ibm.com:OTMS/w21.7.git: [ssh-connection]: Failed (ProviderException) to execute: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DEVICE_ERROR
!STACK 0
org.eclipse.jgit.api.errors.TransportException: git@github.ibm.com:OTMS/w21.7.git: [ssh-connection]: Failed (ProviderException) to execute: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DEVICE_ERROR
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:249)
at org.eclipse.jgit.api.PullCommand.call(PullCommand.java:266)
at org.eclipse.egit.core.op.PullOperation$PullJob.run(PullOperation.java:256)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.eclipse.jgit.errors.TransportException: git@github.ibm.com:OTMS/w21.7.git: [ssh-connection]: Failed (ProviderException) to execute: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DEVICE_ERROR
at org.eclipse.jgit.transport.sshd.SshdSessionFactory.getSession(SshdSessionFactory.java:265)
at org.eclipse.jgit.transport.sshd.SshdSessionFactory.getSession(SshdSessionFactory.java:1)
at org.eclipse.jgit.transport.SshTransport.getSession(SshTransport.java:107)
at org.eclipse.jgit.transport.TransportGitSsh$SshFetchConnection.<init>(TransportGitSsh.java:279)
at org.eclipse.jgit.transport.TransportGitSsh.openFetch(TransportGitSsh.java:152)
at org.eclipse.jgit.transport.FetchProcess.executeImp(FetchProcess.java:153)
at org.eclipse.jgit.transport.FetchProcess.execute(FetchProcess.java:105)
at org.eclipse.jgit.transport.Transport.fetch(Transport.java:1465)
at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:238)
... 3 more
Caused by: org.apache.sshd.common.SshException: [ssh-connection]: Failed (ProviderException) to execute: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DEVICE_ERROR
at org.apache.sshd.common.future.AbstractSshFuture.lambda$verifyResult$2(AbstractSshFuture.java:146)
at org.apache.sshd.common.future.AbstractSshFuture.formatExceptionMessage(AbstractSshFuture.java:206)
at org.apache.sshd.common.future.AbstractSshFuture.verifyResult(AbstractSshFuture.java:145)
at org.apache.sshd.client.future.DefaultAuthFuture.verify(DefaultAuthFuture.java:56)
at org.apache.sshd.client.future.DefaultAuthFuture.verify(DefaultAuthFuture.java:35)
at org.apache.sshd.common.future.VerifiableFuture.verify(VerifiableFuture.java:74)
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:258)
... 11 more
Caused by: sun.security.pkcs11.wrapper.PKCS11Exception: CKR_DEVICE_ERROR
at jdk.crypto.cryptoki/sun.security.pkcs11.wrapper.PKCS11.C_SignFinal(Native Method)
at jdk.crypto.cryptoki/sun.security.pkcs11.P11Signature.engineSign(P11Signature.java:621)
at java.base/java.security.Signature$Delegate.engineSign(Signature.java:1423)
at java.base/java.security.Signature.sign(Signature.java:712)
at org.eclipse.jgit.internal.transport.sshd.pkcs11.Pkcs11Provider.sign(Pkcs11Provider.java:248)
at org.eclipse.jgit.internal.transport.sshd.pkcs11.Pkcs11Provider$Pkcs11Identity.sign(Pkcs11Provider.java:368)
at org.apache.sshd.client.auth.pubkey.UserAuthPublicKey.appendSignature(UserAuthPublicKey.java:446)
at org.apache.sshd.client.auth.pubkey.UserAuthPublicKey.processAuthDataRequest(UserAuthPublicKey.java:413)
at org.apache.sshd.client.auth.AbstractUserAuth.process(AbstractUserAuth.java:88)
at org.apache.sshd.client.session.ClientUserAuthService.processUserAuth(ClientUserAuthService.java:345)
at org.apache.sshd.client.session.ClientUserAuthService.process(ClientUserAuthService.java:267)
at org.apache.sshd.common.session.helpers.CurrentService.process(CurrentService.java:109)
at org.apache.sshd.common.session.helpers.AbstractSession.doHandleMessage(AbstractSession.java:592)
at org.apache.sshd.common.session.helpers.AbstractSession.lambda$handleMessage$0(AbstractSession.java:523)
at org.apache.sshd.common.util.threads.ThreadUtils.runAsInternal(ThreadUtils.java:68)
at org.apache.sshd.common.session.helpers.AbstractSession.handleMessage(AbstractSession.java:522)
at org.apache.sshd.common.session.helpers.AbstractSession.decode(AbstractSession.java:1649)
at org.apache.sshd.common.session.helpers.AbstractSession.messageReceived(AbstractSession.java:483)
at org.eclipse.jgit.internal.transport.sshd.JGitClientSession.messageReceived(JGitClientSession.java:208)
at org.apache.sshd.common.session.helpers.AbstractSessionIoHandler.messageReceived(AbstractSessionIoHandler.java:64)
at org.apache.sshd.common.io.nio2.Nio2Session.handleReadCycleCompletion(Nio2Session.java:407)
at org.apache.sshd.common.io.nio2.Nio2Session$1.onCompleted(Nio2Session.java:380)
at org.apache.sshd.common.io.nio2.Nio2Session$1.onCompleted(Nio2Session.java:375)
at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.lambda$completed$0(Nio2CompletionHandler.java:38)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.completed(Nio2CompletionHandler.java:37)
at java.base/sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:129)
at java.base/sun.nio.ch.Invoker$2.run(Invoker.java:221)
at java.base/sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:113)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
|
|
|
Re: Unexpected reply from ssh-agent: SSH_AGENT_FAILURE [message #1860141 is a reply to message #1860139] |
Wed, 19 July 2023 09:06   |
Eclipse User |
|
|
|
Regarding PKCS11SlotListIndex: first, if it's zero, you don't need to set it. Second, see the README: if you set PKCS11SlotListIndex, also set IgnoreUnknown PKCS11SlotListIndex. Since this mechanism for making OpenSSH ignore this option exists, I left this non-standard option in.
As for the exception regarding the OS X keyring: that appears to be a problem with Eclipse trying to store the PIN in the Eclipse secure storage. Did you check the checkbox in the dialog? I guess so, because otherwise EGit should not even have tried to do that. Apparently you have OS X keyring integration enabled, and that one fails. This is unrelated to PKCS#11. I did try that, and for me it worked, but I don't think I have this OS X keychain integration enabled. (Can't check right now; I'm not at my development machine.)
|
|
| | | | | | | | | | | | | | |
Re: Unexpected reply from ssh-agent: SSH_AGENT_FAILURE [message #1860195 is a reply to message #1860194] |
Fri, 21 July 2023 08:17   |
Eclipse User |
|
|
|
So it's indeed different keys (I was a bit worried that maybe something went wrong and we ended up with the same key), and we cannot use Certificate.getKeyUsage() to skip non-signing keys. Nasty. The token does have flags for the keys, but the Java KeyStore does not give us any access to them. So to skip keys that cannot sign we'd actually have to try to sign something and only consider certificates that give a private key that we can successfully sign with. That'd be most unfortunate.
I don't get why it's using different keys for signing if it loaded them both in the same order in both cases. If it loads the attestation key before the authentication key, it should try the attestation key first in both cases, and fail in both cases.
Did you try the IdentityFile/IdentitiesOnly thing? If you did so for the "New Windows" YubiKey, that might explain the behavior (having the attestation key first, but still trying only the authentication key), and if you did not do so for the "Old Mac" key, then that would also explain the difference.
Other than that I have no clue why it would use different keys in the two cases. It's all just Iterables/Iterators, no HashMaps or anything that might make the order indeterminate involved.
|
|
| | |
Re: Unexpected reply from ssh-agent: SSH_AGENT_FAILURE [message #1860206 is a reply to message #1860200] |
Sat, 22 July 2023 09:08   |
Eclipse User |
|
|
|
Good news: I can confirm that the IdentityFile/IdentitiesOnly configuration works!
On my mac, .ssh/config now looks like this:
Host github.acme.com
PKCS11Provider /usr/local/lib/libykcs11.dylib
Port 22
User git
#LogLevel DEBUG3
#ConnectTimeout 600
#IdentityAgent /private/tmp/com.apple.launchd.RT4X3BfB3J/Listeners
IdentityFile ~/.ssh/yubiKey5cNanoAuthentication
IdentitiesOnly true
I took me a while to "click" that the entry IdentityFile should be IdentityFile ~/.ssh/yubiKey5cNanoAuthentication, and NOT IdentityFile ~/.ssh/yubiKey5cNanoAuthentication.pub
Before trying the IdentityFile config I spent some hours debugging with both YubiKey.s on my Mac So far I have established
The keys on both YubiKeys are loaded in the same order.
With the New/Windows YubiKey, JGit starts with the Attestation Key, then at some point it drops that key, and moves to the Authentication Key, and only attempts to sign with the Authentication Key.
So far I could not work out why the first key was dropped (I was fighting against timeouts), but it was deep in the Apache mina ssh message handling code, which implies some ssh communication was taking place.
With the Old/Mac YubiKey, JGit also starts with the Attestation Key, and keeps using that key up to the point of signing, where it errors out.
I have tried putting breakpoints in UserAuthPublicKey, but nothing stops. For the class on my Mac line 154 is a commented out System.err.println() call.
I will have another go at debugging this evening when it gets dark.
|
|
|
Re: Unexpected reply from ssh-agent: SSH_AGENT_FAILURE [message #1860208 is a reply to message #1860206] |
Sat, 22 July 2023 11:35   |
Eclipse User |
|
|
|
OK... SSH public key authentication with Apache MINA sshd sends two messages:
- Cient sends to Server: "Want to authenticate with this public key: <public key>".
- Server replies whether it would accept that key, provided a correct signature is presented.
- Client sends to Server: "Want to authenticate with this public key: <public key>, and BTW, here's the signature: <signature>".
- Server checks key and signature and replies OK or NOK.
So it appears that for the attestation key of the "Old/Mac" key, the server somehow replies in step 2 "Yes, I know that key, go ahead". But for the attestation key in the "New/Windows" token, the server replies "No, I don't know that key, so I won't accept it for log-in". At that point the client doesn't even try steps 3 and 4 but goes on with step 1 with the next key in the list, which would then be the correct authentication key.
This was already mentioned at https://github.com/Yubico/yubico-piv-tool/issues/421 , but in less detail. Somehow your git server has that Old/Mac attestation key.
Glad that the IdentityFile/IdentitiesOnly works for you. I hope it all also works fine on the command line using OpenSSH.
Re: breakpoint: Apache MINA sshd has two classes named UserAuthPublicKey, one for client part and one for the server part. I meant the client implementation. But the idea about it not being able to figure out a signature algorithm is unlikely anyway. Much more likely is the explanation above.
|
|
| | |
Re: Unexpected reply from ssh-agent: SSH_AGENT_FAILURE [message #1860211 is a reply to message #1860209] |
Sat, 22 July 2023 13:14  |
Eclipse User |
|
|
|
Christopher Lamb wrote on Sat, 22 July 2023 16:49The only downside of the "IdentityFile/IdentitiesOnly" config is that if I switch between multiple YubiKeys, I will need to remember to change .ssh/config.
Export both public keys from both devices, and use two IdentityFile options. Like
Host git.acme.com
PKCS11Provider /path/to/library
IdentityFile ~/.ssh/key_from_device_1
IdentityFile ~/.ssh/key_from_device_2
IdentitiesOnly yes
The only prerequisite is that the library should be able to work with both devices.
Christopher Lamb wrote on Sat, 22 July 2023 16:49.One final thought: If I understand correctly your excellent change is always active if there is a PKCS11Provider entry in the .ssh/config file. I have a nagging doubt at the back of my head: Could this be a breaking change for other users? Would it be safer if PKCS11Provider support was configurable by a checkbox in the Eclipse git ssh preferences?
Assuming that someone already has PKCS11Provider in his SSH config for a host entry that will be used to access a git repository, I think it is safe to assume that the user is happy if that key is used to access the git repository. Command-line git would have used the PKCS#11 keys already, and for JGit the user would, until now, have had to either add that key to the SSH agent, like you did initially, or use a separate "normal" key and have that configured additionally. If EGit now suddenly also can use that PKCS#11 key, that should not cause any trouble.
|
|
|
Goto Forum:
Current Time: Sat May 24 20:03:41 EDT 2025
Powered by FUDForum. Page generated in 0.09862 seconds
|