简体   繁体   中英

How to connect to a remote unix box from java and run unix script in it?

I need help in writing java code that can connect to a remote UNIX box, and run a script on that box. I have scoured the internet, but I have been unable to find proper documentation on how this can be accomplished.

Where is the best place to start reading about this ? What all should I know ?

Any help is appreciated. Thanks.

ssh is probably the best protocol to use for that sort of thing. It's more secure than telnet and can be set to up to use authentication keys so your code won't need to know (or ask the user) for the password to the remote box.

Java Secure Channel (JSch) is a popular pure Java implementation of the ssh protocol.

You can use telnet and/or ssh to connect to the box. Then you can send your command, as you would do it in a terminal. Look out for a telnet/ssh implementation for java with good documentation. Telnet should be simpler, but there is no encryption. Apache has a telnet implementation: http://commons.apache.org/net/

regards Andreas

你可以使用Runtime.exec(java.lang.String)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM