Hi all,
I am new to this kind of application and looking for some sample code how to connect to remote server using SSH , execute commands and get output back using java as programming language.
Thanks in advance.....
Regards, Devayani
Hi all,
I am new to this kind of application and looking for some sample code how to connect to remote server using SSH , execute commands and get output back using java as programming language.
Thanks in advance.....
Regards, Devayani
Have a look at Runtime.exec() Javadoc
Process p = Runtime.exec("ssh myhost");
PrintStream out = new PrintStream(p.getOutputStream());
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream());
out.println("ls -l /home/me");
while (in.ready()) {
String s = in.readLine();
System.out.println(s);
}
out.println("exit");
p.waitFor();
I used ganymede for this a few yeas ago... http://www.cleondris.ch/opensource/ssh2/