Class SshUtils

java.lang.Object
io.gem.api.SshUtils

public final class SshUtils extends Object
SSH utility methods for session creation and command execution.

Wraps Apache Mina SSHD primitives to provide simpler operations used by SBK-GEM for orchestrating remote SBK runs.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates an SSH utility facade for remote SBK orchestration.
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.apache.sshd.client.SshClient
    Create an SSH client configured for host-key and optional SSH-agent authentication.
    static org.apache.sshd.client.session.ClientSession
    createSession(org.apache.sshd.client.SshClient client, ConnectionConfig connConfig, long timeoutSeconds)
    Create and authenticate an SSH ClientSession.
    static void
    runCommand(@NotNull org.apache.sshd.client.session.ClientSession session, String cmd, byte[] input, long timeoutSeconds, @NotNull SshResponse response)
    Execute a command over SSH and provide a bounded binary request on stdin.
    static void
    runCommand(@NotNull org.apache.sshd.client.session.ClientSession session, String cmd, long timeoutSeconds, @NotNull SshResponse response)
    Execute a command over SSH, wiring stdout/stderr to the provided response streams.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SshUtils

      public SshUtils()
      Creates an SSH utility facade for remote SBK orchestration.
  • Method Details

    • createClient

      public static org.apache.sshd.client.SshClient createClient(ConnectionConfig connConfig)
      Create an SSH client configured for host-key and optional SSH-agent authentication.
      Parameters:
      connConfig - connection and host-key policy
      Returns:
      configured, unstarted SSH client
    • createSession

      public static org.apache.sshd.client.session.ClientSession createSession(org.apache.sshd.client.SshClient client, ConnectionConfig connConfig, long timeoutSeconds) throws IOException
      Create and authenticate an SSH ClientSession.
      Parameters:
      client - SSH client (must be started by caller)
      connConfig - connection details (host, user, password, port)
      timeoutSeconds - authentication timeout in seconds
      Returns:
      authenticated session (caller is responsible for closing it)
      Throws:
      IOException - on connection or authentication failure
    • runCommand

      public static void runCommand(@NotNull @NotNull org.apache.sshd.client.session.ClientSession session, String cmd, long timeoutSeconds, @NotNull @NotNull SshResponse response) throws IOException
      Execute a command over SSH, wiring stdout/stderr to the provided response streams.
      Parameters:
      session - non-null SSH session
      cmd - command to execute
      timeoutSeconds - execution timeout in seconds
      response - non-null holder to capture stdout/stderr and exit status
      Throws:
      IOException - on timeout or channel errors
      SocketTimeoutException - when the remote command exceeds its deadline
    • runCommand

      public static void runCommand(@NotNull @NotNull org.apache.sshd.client.session.ClientSession session, String cmd, byte[] input, long timeoutSeconds, @NotNull @NotNull SshResponse response) throws IOException
      Execute a command over SSH and provide a bounded binary request on stdin.
      Parameters:
      session - non-null SSH session
      cmd - command to execute
      input - command standard input
      timeoutSeconds - execution timeout in seconds
      response - response holder
      Throws:
      IOException - on timeout or channel errors
      SocketTimeoutException - when the remote command exceeds its deadline