Java git client using jgit

I'm having difficulty with a git client written in java. I am using jGit library to connect via ssh on git server. The problem is that I do not know how to specify the path to the private key and the passphrase for it. I could not find examples in the jGit documentation about which functions I need to call. From what I read, the jGit library uses JSch to connect to the server using ssh, and JSch supports private keys and passphrases. Does anyone have experience with this or have some kind of working code?

thanks

+8
java jgit passphrase jsch
source share
1 answer

I have never used jGit, but looking at Javadocs (which, it would seem, are not available for online viewing, but can be downloaded ), you need to configure SshSessionFactory (i.e. create a subclass of JSchConfigSessionFactory and override its configure method).

The JSch object supports private keys using addIdentity methods, and passphrases can be specified using UserInfo for each individual JSch Session .

(Disclaimer: JSch Javadoc was written by me.)

+7
source share

All Articles