Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for ssh-agent? #65

Closed
jsundmannorberg opened this issue Aug 24, 2021 · 7 comments
Closed

Support for ssh-agent? #65

jsundmannorberg opened this issue Aug 24, 2021 · 7 comments
Labels
enhancement New feature or request

Comments

@jsundmannorberg
Copy link

jsundmannorberg commented Aug 24, 2021

HI,

Thanks for maintaining this project, it really is a great contribution to the software development community!

WIth older version of Jsch, it was possible to use jsch-agent-proxy https://github.com/ymnk/jsch-agent-proxy but that is not actively developed and no longer compatible with newer versions of Jsch (does not even compile due to changes in the Identity interface). I have been able to make it work by changing a few lines of the source code, but it would be wonderful (and definitely more secure) to have a solution which is maintained by somebody with deep domain knowledge.

Are there any plans to implement support for ssh-agent or possibly fork the existing repository, or maybe build something new entirely?

Regards,
Johan Sundman Norberg

@norrisjeremy
Copy link
Contributor

Hi @jsundmannorberg,

When I have some free time, I may take a look at this and see what it would entail.
Out of curiosity, which components from the original jsch-agent-proxy would you require for your particular use cases?

  1. Do you only require the support for traditional ssh-agent? Or do you also need the support for Pageant?
  2. Do you require the integration support it provides with SSHJ & trilead-ssh2? Or do you require its support with JSch?
  3. Also If you require the traditional ssh-agent support, would you need support for it with Java versions prior to Java 16?

Thanks,
Jeremy

@jsundmannorberg
Copy link
Author

Hi Jeremy!

Thanks for looking at this (if you have time)! It would be incredibly useful to us.

  1. It would be great to support both ssh-agent and Pageant.
  2. We are using this fork of JSch, so that is what we need support for.
  3. For our use case we need to support older Java versions as well, definitely Java 11. And in the future we will also need support for Java 17.

Thanks!
Johan

@norrisjeremy
Copy link
Contributor

HI @jsundmannorberg,

In #64 I've included ssh-agent support based upon jsch-agent-proxy.
Once it is landed, you should be able to activate along the lines of this:

      JSch jsch=new JSch();

      IdentityRepository irepo = new AgentIdentityRepository(new SSHAgentConnector());
      jsch.setIdentityRepository(irepo);

The empty SSHAgentConnector class constructor will attempt to to use Java 16's JEP 380 if you are running on Java 16+, else it will fall back to trying to use the junixsocket library if it is on the classpath. There are also various constructors to manually specify a specific USocketFactory instance (UnixDomainSocketFactory or JUnixSocketFactory, or even a custom implementation), as well as specifying the filesystem path of the ssh-agent's unix domain socket instead of trying to use the SSH_AUTH_SOCK env variable.

I've not tested the PageantConnector class since I am not a Windows user, but if it was working with the old jsch-agent-proxy, then I imagine it should still work now. Using it requires that the JNA library be included on the classpath.

Thanks,
Jeremy

@jsundmannorberg
Copy link
Author

Thanks @norrisjeremy for the amazingly fast response , this looks like exactly what we need!

@mwiede
Copy link
Owner

mwiede commented Sep 7, 2021

@jsundmannorberg can you please test latest release 0.1.66 (should be available on maven central in the next 24 hours), if it fits your needs?

@mwiede mwiede added the enhancement New feature or request label Sep 7, 2021
@jsundmannorberg
Copy link
Author

Absolutely, I will test it as soon as possible

@jsundmannorberg
Copy link
Author

Thanks again for the fast response, this works perfectly for our needs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants