1

I have a ssh command like this

ssh -o ServerAliveInterval=1 -L 27106:name.com:27222 user@differentname.com 

when i enter this it ask for some condition like yes/no : yes then ask for password :

i want to make this work through Java

i have implemented with Runtime but structing at yes or no, its not going to further

below is my code

    Process p = Runtime.getRuntime().exec("ssh -o ServerAliveInterval=1 -L 27106:name.com:27222 user@differentname.com");
PrintStream out = new PrintStream(p.getOutputStream());
BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()));

while (in.ready()) {
  String s = in.readLine();
  System.out.println(s);
}
System.out.println("exit");

p.waitFor();

any one please help me on achieving this. I have looked Jsch library didn't get it. please help me on this. I really appreciate it.

mhvb
  • 31
  • 4

0 Answers0