Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jgit-dev] SSH Gerrit key with JGit


So I ran into a weird problem these days. I have an app that uses Jgit high level API to perform GIT commands. Recently Gerrit has also come into play and with it the need to register the public SSH key, which is all fine. The problem arises if I start the application without any key generated in my .ssh directory. As expected an exception is thrown which is correctly treated informing me I have to generate the key and register on Gerrit. I also have a Retry button in this window, meaning the application does not close when this happens. So, if I create the key and register it on Gerrit and then hit "Retry" I still get an Auth fail exception. But if I do close the app and simply start again it works like a charm.

My guess is that the SSH session used in the first try to clone the repo is the same being used on subsequent tries and therefore it has not refreshed the status of the private/public key pair. I think I even managed to confirm this by checking the SSHSessionFactory before and after. So my question is, is there a way to tell JGit to refresh the JSch session for it to retrieve the new key generated? Or am I completely out of line and the problem is something else entirely?


The Chinese mafia is watching you!

Back to the top