Class SshUtils


  • public final class SshUtils
    extends java.lang.Object
    Example utility to use SSH via Apache Mina SSHD
    Author:
    Drew Thorstensen
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String join​(java.util.List<java.lang.String> status)  
      static SshResponse runCommand​(SshConnection conn, java.lang.String cmd, long timeout)
      Runs a SSH command against a remote system.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • runCommand

        public static SshResponse runCommand​(SshConnection conn,
                                             java.lang.String cmd,
                                             long timeout)
                                      throws SshTimeoutException,
                                             java.io.IOException
        Runs a SSH command against a remote system.
        Parameters:
        conn - Defines the connection to the system.
        cmd - The command to run. Should generally be fully qualified (ex. instead of 'ls -la', use '/bin/ls -la')
        timeout - The amount of time to wait for the command to run before timing out. This is in seconds. This is used as two separate timeouts, one for login another for command execution.
        Returns:
        The SshResponse contains the output of a successful command.
        Throws:
        SshTimeoutException - Raised if the command times out.
        java.io.IOException - Raised in the event of a general failure (wrong authentication or something of that nature).
      • join

        public static java.lang.String join​(java.util.List<java.lang.String> status)