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> >
