• 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())
 ).exec("uptime");
}

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

<dependency>
  <groupId>com.jcabi</groupId>
  <artifactId>jcabi-ssh</artifactId>
  <version>1.5.2</version>
</dependency>

Cutting Edge Version

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

<repositories>
  <repository>
    <id>oss.sonatype.org</id>
    <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
  </repository>
</repositories>
<dependencies>
  <dependency>
    <groupId>com.jcabi</groupId>
    <artifactId>jcabi-ssh</artifactId>
    <version>2.0-SNAPSHOT</version>
  </dependency>
</dependencies>