I need to execute some sequence of commands at the remote server via ssh, using sshj library.
I do
Session session = ssh.startSession();
Session.Command cmd = session.exec("ls -l");
System.out.println(IOUtils.readFully(cmd.getInputStream()).toString());
cmd.join(10, TimeUnit.SECONDS);
Session.Command cmd2 = session.exec("ls -a");
System.out.println(IOUtils.readFully(cmd2.getInputStream()).toString());
and it throws me
net.schmizz.sshj.common.SSHRuntimeException: This session channel is
all used up
But I can't recreate session for every single command, because this example it will show home directory list, but not the /some/dir list.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…