Hi, I am using ganymed-ssh2 java library to successfully execute remote commands on a Linux workstation.
But now there is a situation where I need to execute a command, but this requires me to add a password ... for example:
sudo /usr/bin/some_process please enter your password:
I used to execute remote cmd as follows:
Session sess = conn.openSession(); sess.execCommand("uname -a && date && uptime && who"); System.out.println("Here is some information about the remote host:"); InputStream stdout = new StreamGobbler(sess.getStdout()); BufferedReader br = new BufferedReader(new InputStreamReader(stdout)); while (true) { String line = br.readLine(); if (line == null) break; System.out.println(line); } System.out.println("ExitCode: " + sess.getExitStatus()); sess.close(); conn.close();
I am afraid that it is impossible to execute commands that require a password with this library.
Someone can give me a solution or an alternative to resolve this.
thanks!
source share