2

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.

3 Answers 3

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Great.. I found out about JSch and seems I can do what I wanted with it.. Thanks...
2

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

2 Comments

@andreas... I need a secure connection.. Does that mean I need to use ssh and not telnet ?
Yes, you have to use ssh. Telnet is not secure.
1

You could use Runtime.exec(java.lang.String)

2 Comments

@michael... Can I implement a secure connection using it ??

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.