0

Is it possible to run command line on a remote machine (not on the server machine where the application is hosted).

I understand Runtime.getRuntime().exec(".."); will try to run the script on the server machine. Is my understanding correct and is there a way to achieve what I need?

0

1 Answer 1

3

Runtime.getRuntime().exec launches a process on the local machine, not a remote one. Wether that process represents a command line interface or not will be determined by the executable that's run, and the underlying platform.

In order to invoke processes on remote machines you need to:

  • Invoke a remoting type command, like rsh or ssh
  • Utilize a remoting third party library, like Jsch
Sign up to request clarification or add additional context in comments.

1 Comment

Well ... I have seen Runtime.getRuntime().exec used as part of an attack on a server. It started sh and then piped input/output over a socket to a remote controlling server. That way, the remote server was able to issue commands to the victim server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.