Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Connect to repo using SSH

The JSSH library used by JGit picks up SSH keys from ~/.ssh/ by default, IIRC. If you need more control you can fully configure this process with a TransportConfigCallback:

http://download.eclipse.org/jgit/docs/jgit-3.1.0.201310021548-r/apidocs/org/eclipse/jgit/api/TransportConfigCallback.html

For instance, if a client needs to replace the SshSessionFactorys on any SSHTransport used, they can set the TransportConfigCallback on the JGit API command - once the transport has been created by the command, the callback will be invoked and passed the transport instance, which the client can then inspect and configure as necessary.

Here's an example in Agit of using the callback to do custom SSH challenge generation - this may be slightly more involved than what you need, you can probably get away with one of the default JSSH Identity implementations:

https://github.com/rtyley/agit/blob/35c48634/agit/src/main/java/com/madgag/agit/git/AgitTransportConfig.java#L44-L46
https://github.com/rtyley/agit/blob/35c48634/agit/src/main/java/com/madgag/agit/ssh/AndroidSshSessionFactory.java
https://github.com/rtyley/agit/blob/35c48634/agit/src/main/java/com/madgag/ssh/authagent/client/jsch/SSHAgentIdentity.java




On 3 June 2014 07:21, Bhushan Nagaraj <bhushan154@xxxxxxxxx> wrote:
Hi all,

Using jgit API, how do I connect to a repository using a SSH key and passphrase?

Cheers
Bhushan
bhushan154@xxxxxxxxx



_______________________________________________
jgit-dev mailing list
jgit-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jgit-dev


Back to the top