I wonder if the better solution is to create a ConnectionFactory class within TransportGitSsh and use a setConnectionFactory method. Then callers can still use Transport.open() to get a Transport instance, and if it is an SSH type set the factory, and if its not, leave it alone. This frees callers from needing to parse the URIish on their own and determine the protocol that JGit will use.

It might be a few more lines of code to add the factory, but the extra level of indirection might be useful.

A different approach would be to start removing the JSch information from TransportGitSsh and make a slightly more generic RemoteCommandConnection (by extracting TransportGitSsh.Connection into a new top level class), and rename TransportGitSsh to TransportGitRemoteCommand. Then we can hide all of the JSch stuff inside of a JSchRemoteCommandConnection and start to free JGit from only supporting JSch. (I'd like to also support MINA SSHD client as it looks to be a more solid implementation.)