Package io.gem.api

Class SshUtils

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

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

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

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    copyDirectory(org.apache.sshd.client.session.ClientSession session, String srcPath, String dstPath)
    Recursively copy a directory to a remote path using SCP.
    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, long timeoutSeconds, @NotNull SshResponse response)
    Execute a command over SSH, wiring stdout/stderr to the provided response streams.

    Methods inherited from class java.lang.Object

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

    • SshUtils

      public SshUtils()
  • Method Details

    • 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
    • copyDirectory

      public static void copyDirectory(org.apache.sshd.client.session.ClientSession session, String srcPath, String dstPath) throws IOException
      Recursively copy a directory to a remote path using SCP.
      Parameters:
      session - SSH session
      srcPath - local source path
      dstPath - remote destination path
      Throws:
      IOException - on copy failure