Java git client using jgit
Asked Answered
B

1

8

I am having some difficulties with a git client written in java. I am using the jGit library to connect through ssh on the git server. The problem is that i don't know how to specify the path to the private key and the passphrase for it. I couldn't find any examples in the jGit documentation about what functions i need to call. From what i read the jGit library is using JSch to connect to the server using ssh and JSch supports private keys and passphrases. Does anyone have any experience with this or has some working code?

Thank you

Bowler answered 31/10, 2011 at 8:29 Comment(0)
N
7

I didn't ever use jGit, but from looking at the Javadocs (which are seemingly not online browsable, but can be downloaded) you need to configure a SshSessionFactory (i.e. create a subclass of JSchConfigSessionFactory, and override its configure method).

The JSch object supports private keys with its addIdentity methods, and the passphrases can be given with UserInfo objects to each individual JSch Session.

(Disclaimer: The JSch Javadoc was written by me.)

Nutt answered 31/10, 2011 at 15:37 Comment(3)
@Bowler it would be helpful if you could share some more information, how it worked for you. I am still struggling to get this thru. I get errors :com.jcraft.jsch.JSchException: Auth fail at com.jcraft.jsch.Session.connect(Session.java:519) at org.eclipse.jgit.transport.JschConfigSessionFactory.getSession(JschConfigSessionFactory.java:117)Frick
I understand it has been close to 6 years but any help on this would be awesome.Frick
Sorry, i don't have the code of my app anymore but if you can post here some of the non working code maybe me or somebody else here can help you out.Bowler

© 2022 - 2024 — McMap. All rights reserved.