I want to execute ssh-keygen in my local computer. but when i run the code below, ssh-keygen only run until :
Generating public/private rsa key pair.
Enter file in which to save the key (/cygdrive/c/Users/USER/.ssh/id_rsa):
BUILD SUCCESSFUL (total time: 0 seconds)
//ssh-keygen execution stop at here only.
Result i want is like this:
Generating public/private rsa key pair.
Enter file in which to save the key (/cygdrive/c/Users/USER/.ssh/id_rsa): //press enter
Enter passphrase (empty for no passphrase): //press enter
Enter same passphrase again: //press enter
//http://commons.apache.org/proper/commons-exec/tutorial.html
import java.io.IOException;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.ExecuteWatchdog;
public class ApacheRunSSHKEygen {
public static void main(String[] args) throws IOException {
try {
String line = "C:\\ExecuteSSH\\ssh-keygen.exe"; // path to ssh-keygen.exe
CommandLine cmdLine = CommandLine.parse(line);
DefaultExecutor executor = new DefaultExecutor();
//watchdog
executor.setExitValue(1);
ExecuteWatchdog watchdog = new ExecuteWatchdog(60000);
executor.setWatchdog(watchdog);
int exitValue = executor.execute(cmdLine); //execute ssh-keygen
}
catch (Exception exc){
System.out.println("error" + exc);/*handle exception*/}
}
}
What is actually wrong in my code. how can i run the ssh-keygen properly? thank you in advance for the helps.