• 1.5.2

Java SSH Client

Read this introduction article: Simple Java SSH Client.

It is as simple as this:

import com.jcabi.ssh.Shell;
import com.jcabi.ssh.SSH;
Shell shell = new SSH("example.com", 22, "username", "key...");
String stdout = new Shell.Plain(shell).exec("echo 'Hello, world!'");

There is also a convenient SSHD class, a runner of ssh daemon, for unit testing:

try (SSHD sshd = new SSHD()) {
  String uptime = new Shell.Plain(
    SSH(sshd.host(), sshd.login(), sshd.port(), sshd.key())

The only dependency you need is (you can also download jcabi-ssh-1.5.2.jar and add it to the classpath):


Cutting Edge Version

If you want to use current version of the product, you can do it with this configuration in your pom.xml: