I'm building an app that needed to open a new SSH connection for the user, and then send automatically a command. The app need to run on Windows, i thought about using putty to the SSH client and then send the command but the command don't sent to putty. Anyone have any idea how can i implement this?
This is my code:
String command = puttyPath + " -ssh user@localhost"
process = Runtime.getRuntime().exec(command);
OutputStream out = process.getOutputStream();
Writer writer = new OutputStreamWriter(out);
writer.write(secondCommand);
writer.flush();
process.waitFor(600_000, TimeUnit.SECONDS);
Is there any possible to send only one command to putty and the putty will know to send it to the remote server?
You can try to add for your command the "-m" and a file with secondCommand. For more read about enter link description here