You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Thomas Wolf (Jira)" <ji...@apache.org> on 2021/03/16 07:43:00 UTC

[jira] [Commented] (SSHD-1143) Example for JGit TransportConfigCallback with MINA

    [ https://issues.apache.org/jira/browse/SSHD-1143?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17302290#comment-17302290 ] 

Thomas Wolf commented on SSHD-1143:
-----------------------------------

JGit has its own implementation in bundle {{org.eclipse.jgit.ssh.apache}}. It's what is used in EGit, and I think Gerrit is also using it now. I've given some hints on configuring it in a recent [EGit/JGit forum post|https://www.eclipse.org/forums/index.php/t/1106995/].

If you want to use different {{SshSessionFactory}} instances for different connections, you can set them indeed in a {{TransportConfigCallback}}. But why would you want to do that? Using the same factory instance for different connections is fine.

If you want to run several git operations over the same SSH connection, you'll have to implement your own {{SshSessionFactory}}, and you'll have to figure out yourself how and when it's safe to close a session. And what to do if the server decides to close a session when it has been idle for too long.

As an aside: I never understood why some places on the net recommend using a {{TransportConfigCallback}} to set the factory. Personally I've never needed to do that; setting the single global factory has always been good enough for me. But possibly my use cases are overly simplistic. 

> Example for JGit TransportConfigCallback with MINA
> --------------------------------------------------
>
>                 Key: SSHD-1143
>                 URL: https://issues.apache.org/jira/browse/SSHD-1143
>             Project: MINA SSHD
>          Issue Type: Improvement
>    Affects Versions: 2.5.1
>            Reporter: Joern Guy Suess
>            Priority: Major
>
> JGit used to rely on JSch as its transport provider, but changed because JSch does not accept certain keys, including some OpenSSH ones.
> If you are using a passphrase-encrypted key with JGit, the recommended approach with JSch used to be [to override a configuration callback, as shown in this blog article|https://blog.sebastian-daschner.com/entries/access-git-from-java].
> The alternative is to [set a shared session factory|https://stackoverflow.com/questions/12502452/how-do-you-set-the-configuration-for-jschconfigsessionfactory-for-jgit-so-that-p#answer-15290861] and this [also what the Apache MINA team recommends with a pointer to the cost of creating sessions on demand|https://github.com/apache/mina-sshd/blob/master/docs/git.md#user-content-client-side].
> However, my issue with this is that it sets a specific provider for the whole system scope. Consequently, I would like to implement [{{TransportConfigCallback}}|https://archive.eclipse.org/jgit/docs/jgit-2.0.0.201206130900-r/apidocs/org/eclipse/jgit/api/TransportConfigCallback.html]. Ultimately, this requires to adapt [{{SshSessionFactory}}|https://archive.eclipse.org/jgit/docs/jgit-2.0.0.201206130900-r/apidocs/org/eclipse/jgit/transport/SshSessionFactory.html] to MINA's session initialization code and produce a [{{RemoteSession}}|https://archive.eclipse.org/jgit/docs/jgit-2.0.0.201206130900-r/apidocs/org/eclipse/jgit/transport/RemoteSession.html].
> Would it be possible to provide an example or some boilerplate for this case?
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@mina.apache.org
For additional commands, e-mail: dev-help@mina.apache.org