rounak agarwal
rounak agarwal

Reputation: 11

SSH connection with Java using different port

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

Answers (1)

aleroot
aleroot

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

Related Questions