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
JGit is a relatively full-featured implementation of Git written in Java and is widely used in the Java community. The JGit project is under the Eclipse umbrella, and its home can be found at JGit.
Eclipse JGit™ is a pure Java implementation of the Git version control system. Git is a distributed SCM, which means every developer has a full copy of all history of every revision of the code, making queries against the history very fast and versatile.
2.1 Choose the repository where you want to add the code. 2.2 Click on Add File and then click on the Create new file option. 2.4 Make sure to add the extension of the file, for example, “.
If you want to use Git from within a Java program, there is a fully featured Git library called JGit. JGit is a relatively full-featured implementation of Git written natively in Java, and is widely used in the Java community.
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.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With