While Alon Bar-Lev is correct, I have had cases where when an illegal command was sent to a remote end it closed the connection. Be aware that there are edge cases that may impact your application where the connection will get closed.
Claude On Sun, May 26, 2019 at 8:05 PM Alon Bar-Lev <[email protected]> wrote: > Hi, > Always prefer keys over passwords when interacting with remote servers. > You can reuse the session, aka keep it as a member. > You should close the session yourself. > You can find a simplified example here[1]. > Regards, > Alon > > [1] > > https://github.com/oVirt/ovirt-engine/blob/master/backend/manager/modules/uutils/src/main/java/org/ovirt/engine/core/uutils/ssh/SSHClient.java > > > On Sun, May 26, 2019 at 9:57 PM Dor Ben Dov <[email protected]> > wrote: > > > Hi Everyone, > > > > At the moment I have a method to 'init' the user/password etc with the > > connect method of sshclient. > > And I have different method where I do the executeremotecommand. > > > > In the code I am doing connect and then executeremotecommand in several > > places / methods etc. > > > > My question - the right way of work will be to open the session once, > keep > > it let's say as a member in the class > > And use it everywhere ? > > > > What about closing the session, am I responsible on closing the session ? > > > > Regards, > > Dor > > This email and the information contained herein is proprietary and > > confidential and subject to the Amdocs Email Terms of Service, which you > > may review at https://www.amdocs.com/about/email-terms-of-service < > > https://www.amdocs.com/about/email-terms-of-service> > > > -- I like: Like Like - The likeliest place on the web <http://like-like.xenei.com> LinkedIn: http://www.linkedin.com/in/claudewarren
