Class OsCommandRequestExecutor
java.lang.Object
org.sentrysoftware.metricshub.extension.oscommand.OsCommandRequestExecutor
Provides functionality to execute remote SSH commands, manage SSH authentication, and transfer files to remote hosts.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic org.sentrysoftware.ssh.SshClientcreateSshClientInstance(String hostname) Creates a new instance of theSshClient.static StringrunRemoteSshCommand(@NonNull String hostname, @NonNull String username, char[] password, File keyFilePath, String command, long timeout, List<File> localFiles, String noPasswordCommand) Use ssh-client in order to run ssh command.
-
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
Creates a new instance of theSshClient.- Parameters:
hostname- The hostname.- Returns:
- A
SshClientinstance.
-