Package io.gem.api
Class SshUtils
java.lang.Object
io.gem.api.SshUtils
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 -
Method Summary
Modifier and TypeMethodDescriptionstatic voidcopyDirectory(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.ClientSessioncreateSession(org.apache.sshd.client.SshClient client, ConnectionConfig connConfig, long timeoutSeconds) Create and authenticate an SSHClientSession.static voidrunCommand(@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.
-
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 SSHClientSession.- 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 sessioncmd- command to executetimeoutSeconds- execution timeout in secondsresponse- 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 sessionsrcPath- local source pathdstPath- remote destination path- Throws:
IOException- on copy failure
-