Hi I just recently discovered Apache SSHD and am testing it to see if we can use this to use as a client for remote SSH servers.
As part of this, I'd like to access/use keys within the local SSH agent I have running on my machine. I couldn't find any examples for this exact case, but yesterday I was playing with something like this: try (SshClient client = SshClient.setUpDefaultClient()) { client.getProperties().put(SshAgent.SSH_AUTHSOCKET_ENV_NAME, System.getenv().get("SSH_AUTH_SOCK")); org.apache.sshd.client.auth.pubkey.UserAuthPublicKeyFactory factory = new org.apache.sshd.client.auth.pubkey.UserAuthPublicKeyFactory(); client.setUserAuthFactories(Collections.<NamedFactory<UserAuth>>singletonList(factory)); client.setAgentFactory(new UnixAgentFactory()); client.start(); . . . The problem I ran into is that the AgentClient appears to require the Apache Portable Runtime (APR) and the tcnative-1 library (stack trace below). Is there any way to access the local SSH agent without requiring a binary install on the machines where I'm using the SshClient? Thanks in advance, Patrick Exception in thread "main" org.apache.sshd.common.SshException: Error loading Apache Portable Runtime (APR). at org.apache.sshd.agent.unix.AgentClient.<init>(AgentClient.java:77) at org.apache.sshd.agent.unix.UnixAgentFactory.createClient(UnixAgentFactory.java:99) at org.apache.sshd.client.auth.pubkey.UserAuthPublicKeyIterator.<init>(UserAuthPublicKeyIterator.java:59) at org.apache.sshd.client.auth.pubkey.UserAuthPublicKey.init(UserAuthPublicKey.java:77) at org.apache.sshd.client.session.ClientUserAuthService.tryNext(ClientUserAuthService.java:328) at org.apache.sshd.client.session.ClientUserAuthService.processUserAuth(ClientUserAuthService.java:252) at org.apache.sshd.client.session.ClientUserAuthService.process(ClientUserAuthService.java:199) at org.apache.sshd.common.session.helpers.AbstractSession.doHandleMessage(AbstractSession.java:530) at org.apache.sshd.common.session.helpers.AbstractSession.handleMessage(AbstractSession.java:463) at org.apache.sshd.common.session.helpers.AbstractSession.decode(AbstractSession.java:1325) at org.apache.sshd.common.session.helpers.AbstractSession.messageReceived(AbstractSession.java:424) at org.apache.sshd.common.session.helpers.AbstractSessionIoHandler.messageReceived(AbstractSessionIoHandler.java:67) at org.apache.sshd.common.io.nio2.Nio2Session.handleReadCycleCompletion(Nio2Session.java:285) at org.apache.sshd.common.io.nio2.Nio2Session$2.onCompleted(Nio2Session.java:265) at org.apache.sshd.common.io.nio2.Nio2Session$2.onCompleted(Nio2Session.java:262) at org.apache.sshd.common.io.nio2.Nio2CompletionHandler$1.run(Nio2CompletionHandler.java:37) at java.security.AccessController.doPrivileged(Native Method) at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.completed(Nio2CompletionHandler.java:34) at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126) at sun.nio.ch.Invoker$2.run(Invoker.java:218) at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at java.lang.Thread.run(Thread.java:745) Caused by: java.lang.RuntimeException: Error loading Apache Portable Runtime (APR). at org.apache.sshd.agent.unix.AprLibrary.<init>(AprLibrary.java:68) at org.apache.sshd.agent.unix.AprLibrary.initialize(AprLibrary.java:92) at org.apache.sshd.agent.unix.AprLibrary.getInstance(AprLibrary.java:81) at org.apache.sshd.agent.unix.AgentClient.<init>(AgentClient.java:63) ... 23 more Caused by: java.lang.UnsatisfiedLinkError: no tcnative-1 in java.library.path, no libtcnative-1 in java.library.path(/Users/sglo/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.) at org.apache.tomcat.jni.Library.<init>(Library.java:73) at org.apache.tomcat.jni.Library.initialize(Library.java:174) at org.apache.sshd.agent.unix.AprLibrary.<init>(AprLibrary.java:63) ... 26 more