Class OsCommandRequestExecutor

java.lang.Object
org.sentrysoftware.metricshub.extension.oscommand.OsCommandRequestExecutor

public class OsCommandRequestExecutor extends Object
Provides functionality to execute remote SSH commands, manage SSH authentication, and transfer files to remote hosts.
  • Constructor Details

    • OsCommandRequestExecutor

      public OsCommandRequestExecutor()
  • Method Details

    • runRemoteSshCommand

      public static String runRemoteSshCommand(@NonNull @NonNull String hostname, @NonNull @NonNull String username, char[] password, File keyFilePath, String command, long timeout, List<File> localFiles, String noPasswordCommand) throws ClientException
      Use ssh-client in order to run ssh command.
      Parameters:
      hostname - The hostname or IP address to connect to.
      username - The SSH username.
      password - The SSH password as a character array.
      keyFilePath - The path to the SSH key file.
      command - The SSH command to execute.
      timeout - The timeout for the command execution in seconds.
      localFiles - List of local files to be transferred to the remote host.
      noPasswordCommand - The command to execute without password.
      Returns:
      The result of the SSH command.
      Throws:
      ClientException - If an error occurs during the SSH command execution.
    • createSshClientInstance

      public static org.sentrysoftware.ssh.SshClient createSshClientInstance(String hostname)
      Creates a new instance of the SshClient.
      Parameters:
      hostname - The hostname.
      Returns:
      A SshClient instance.