Package org.ndviet.library.ssh
Class SshUtils
java.lang.Object
org.ndviet.library.ssh.SshUtils
Example utility to use SSH via Apache Mina SSHD
- Author:
- Drew Thorstensen
-
Method Summary
Modifier and TypeMethodDescriptionstatic Stringstatic SshResponserunCommand(SshConnection conn, String cmd, long timeout) Runs a SSH command against a remote system.
-
Method Details
-
runCommand
public static SshResponse runCommand(SshConnection conn, String cmd, long timeout) throws SshTimeoutException, IOException Runs a SSH command against a remote system.- Parameters:
conn- Defines the connection to the system.cmd- The command to run. Should generally be fully qualified (ex. instead of 'ls -la', use '/bin/ls -la')timeout- The amount of time to wait for the command to run before timing out. This is in seconds. This is used as two separate timeouts, one for login another for command execution.- Returns:
- The
SshResponsecontains the output of a successful command. - Throws:
SshTimeoutException- Raised if the command times out.IOException- Raised in the event of a general failure (wrong authentication or something of that nature).
-
join
-