|Re: [jgit-dev] SSH Gerrit key with JGit|
On Tue, Dec 20, 2011 at 09:25, Itzack <itzack@xxxxxxxxx> wrote: > Well, answering my own plight I figured out a way to ensure that JGIT is > always using the current key present in the home/.ssh folder. I created a > class that inherits from JschConfigSessionFactory and overrode the getJSch > method such that I intercepted the result from the super.getJSch to remove > all identities present and retrieve the private key present in home/.ssh > folder with the addIdentity method. Then it was only a matter of setting the > instance of the SshSessionFactory with its setInstance method to my custom > class and it worked like a charm. > > Not sure if this is the most elegant or even correct way to do this, but it > works ok. This is a valid way to use the code, and is one reason why we allow applications to replace the SshSessionFactory. But I really think this is a bug in JGit, we should be able to pick up the new keys, especially after an authentication failure if we haven't looked at ~/.ssh recently.
Back to the top