Reputation: 11
How can I connect to an SSH server in Java using other than 22 port . I just want to connect to the SSH server and run one command and then wait for 20-30 sec and run other command.
Upvotes: 0
Views: 846
Reputation: 72626
Try jcabi-ssh, it is a very simple and convenient wrapper of JSch.
Let's say you want to connect to a Server on port 453, see below example :
import com.jcabi.ssh.Shell; import com.jcabi.ssh.SSH; Shell shell = new SSH("example.com", 453, "username", "key...");
Upvotes: 2