Package com.jcabi.ssh

Class Sshd

  • All Implemented Interfaces:
    Closeable, AutoCloseable

    public final class Sshd
    extends Object
    implements Closeable
    Test SSHD daemon (only for Linux).

    It is a convenient class for unit testing of your SSH clients:

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

    If you forget to call close(), SSH daemon will be up and running until a shutdown of the JVM.

    Since:
    1.0
    Suppressed Checkstyle violations:
    MultipleStringLiteralsCheck (500 lines), ClassDataAbstractionCouplingCheck (500 lines)
    • Method Detail

      • home

        public File home()
        Get home dir.
        Returns:
        Dir
      • login

        public static String login()
        Get user name to login.
        Returns:
        User name
      • host

        public static String host()
        Get host of SSH.
        Returns:
        Hostname
        Since:
        1.1
      • port

        public int port()
        Get port.

        Don't forget to start

        Returns:
        Port number
        Since:
        1.1