Our recommendation is definitely to have *one* SshClient instance
throughout the
application and (re-)use it to create as many SSH sessions as needed,

public static void main(String[] args) {

SshClient client = ... initialize the client ...

client.start();

try {

     ...run the application process using the client instance

} finally {

client.stop();   // destroy the client instance when 'main' ends and
application terminates.

}

}


If you need different setups for accessing different servers (e.g., ciphers
MAC(s), signatures, compression) these
can be done at the *session* level. Basically, the session inherits its
defaults from the client, but can
be overridden if necessary.via SessionListener(s) or directly - depending
on the use-case.

>>> I have an application that uses SshClient and was wondering what the
best
usage pattern was.  Is it better to have a single long living SshClient
that is used throughout the application or to open and close the SshClient
as needed?  My particular use case is centered around a recurring task that
essentially polls for information.

Reply via email to