public interface SshTool extends ShellTool
The config keys in this class can be supplied (or their string equivalents, where the flags/props take Map<String,?>
)
to influence configuration, either for the tool/session itself or for individual commands.
To specify some of these properties on a global basis, use the variants of the keys here
contained in ConfigKeys
(which are generally "brooklyn.ssh.config." prefixed to the names of keys here).
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
BROOKLYN_CONFIG_KEY_PREFIX
Public-facing global config keys for Brooklyn are defined in ConfigKeys,
and have this prefix pre-prended to the config keys in this class.
|
static ConfigKey<java.lang.Boolean> |
PROP_ALLOCATE_PTY |
static ConfigKey<java.lang.Long> |
PROP_CONNECT_TIMEOUT |
static ConfigKey<java.lang.String> |
PROP_HOST |
static ConfigKey<java.lang.Long> |
PROP_LAST_ACCESS_DATE |
static ConfigKey<java.lang.Long> |
PROP_LAST_MODIFICATION_DATE |
static ConfigKey<java.lang.Integer> |
PROP_OWNER_UID |
static ConfigKey<java.lang.String> |
PROP_PASSWORD |
static ConfigKey<java.lang.String> |
PROP_PERMISSIONS |
static ConfigKey<java.lang.Integer> |
PROP_PORT |
static ConfigKey<java.lang.String> |
PROP_PRIVATE_KEY_DATA |
static ConfigKey<java.lang.String> |
PROP_PRIVATE_KEY_FILE |
static ConfigKey<java.lang.String> |
PROP_PRIVATE_KEY_PASSPHRASE |
static ConfigKey<java.lang.Long> |
PROP_SESSION_TIMEOUT |
static ConfigKey<java.lang.Long> |
PROP_SSH_RETRY_DELAY |
static ConfigKey<java.lang.Integer> |
PROP_SSH_TRIES |
static ConfigKey<java.lang.Long> |
PROP_SSH_TRIES_TIMEOUT |
static ConfigKey<java.lang.Boolean> |
PROP_STRICT_HOST_KEY_CHECKING |
static ConfigKey<java.lang.String> |
PROP_TOOL_CLASS |
static ConfigKey<java.lang.String> |
PROP_USER |
PROP_DIRECT_HEADER, PROP_ERR_STREAM, PROP_EXEC_ASYNC, PROP_EXEC_ASYNC_POLLING_TIMEOUT, PROP_EXEC_TIMEOUT, PROP_LOCAL_TEMP_DIR, PROP_NO_DELETE_SCRIPT, PROP_NO_EXTRA_OUTPUT, PROP_OUT_STREAM, PROP_RUN_AS_ROOT, PROP_SCRIPT_DIR, PROP_SCRIPT_HEADER, PROP_SEPARATOR, PROP_SUMMARY
Modifier and Type | Method and Description |
---|---|
void |
connect() |
void |
connect(int maxAttempts)
Deprecated.
since 0.7.0; (since much earlier) this ignores the argument in favour of
PROP_SSH_TRIES |
int |
copyFromServer(java.util.Map<java.lang.String,?> props,
java.lang.String pathAndFileOnRemoteServer,
java.io.File local)
Copies the file from the server at the given path.
|
int |
copyToServer(java.util.Map<java.lang.String,?> props,
byte[] contents,
java.lang.String pathAndFileOnRemoteServer) |
int |
copyToServer(java.util.Map<java.lang.String,?> props,
java.io.File localFile,
java.lang.String pathAndFileOnRemoteServer)
Copies the file to the server at the given path.
|
int |
copyToServer(java.util.Map<java.lang.String,?> props,
java.io.InputStream contents,
java.lang.String pathAndFileOnRemoteServer)
Closes the given input stream before returning.
|
void |
disconnect() |
int |
execCommands(java.util.Map<java.lang.String,?> properties,
java.util.List<java.lang.String> commands) |
int |
execCommands(java.util.Map<java.lang.String,?> properties,
java.util.List<java.lang.String> commands,
java.util.Map<java.lang.String,?> env)
Executes the set of commands using ssh exec.
|
int |
execScript(java.util.Map<java.lang.String,?> props,
java.util.List<java.lang.String> commands) |
int |
execScript(java.util.Map<java.lang.String,?> props,
java.util.List<java.lang.String> commands,
java.util.Map<java.lang.String,?> env)
Executes the set of commands in a shell script.
|
boolean |
isConnected() |
static final java.lang.String BROOKLYN_CONFIG_KEY_PREFIX
static final ConfigKey<java.lang.String> PROP_TOOL_CLASS
static final ConfigKey<java.lang.String> PROP_HOST
static final ConfigKey<java.lang.Integer> PROP_PORT
static final ConfigKey<java.lang.String> PROP_USER
static final ConfigKey<java.lang.String> PROP_PASSWORD
static final ConfigKey<java.lang.String> PROP_PRIVATE_KEY_FILE
static final ConfigKey<java.lang.String> PROP_PRIVATE_KEY_DATA
static final ConfigKey<java.lang.String> PROP_PRIVATE_KEY_PASSPHRASE
static final ConfigKey<java.lang.Boolean> PROP_STRICT_HOST_KEY_CHECKING
static final ConfigKey<java.lang.Boolean> PROP_ALLOCATE_PTY
static final ConfigKey<java.lang.Long> PROP_CONNECT_TIMEOUT
static final ConfigKey<java.lang.Long> PROP_SESSION_TIMEOUT
static final ConfigKey<java.lang.Integer> PROP_SSH_TRIES
static final ConfigKey<java.lang.Long> PROP_SSH_TRIES_TIMEOUT
static final ConfigKey<java.lang.Long> PROP_SSH_RETRY_DELAY
static final ConfigKey<java.lang.String> PROP_PERMISSIONS
static final ConfigKey<java.lang.Long> PROP_LAST_MODIFICATION_DATE
static final ConfigKey<java.lang.Long> PROP_LAST_ACCESS_DATE
static final ConfigKey<java.lang.Integer> PROP_OWNER_UID
void connect()
SshException
void connect(int maxAttempts)
PROP_SSH_TRIES
maxAttempts
- SshException
void disconnect()
boolean isConnected()
int execScript(java.util.Map<java.lang.String,?> props, java.util.List<java.lang.String> commands, java.util.Map<java.lang.String,?> env)
ShellTool
Optional properties are the same common ones as for ShellTool.execCommands(Map, List, Map)
with the addition of:
execScript
in interface ShellTool
SshException
- If failed to connect#execScript(Map, List, Map)}
int execScript(java.util.Map<java.lang.String,?> props, java.util.List<java.lang.String> commands)
execScript
in interface ShellTool
execScript(Map, List, Map)
int execCommands(java.util.Map<java.lang.String,?> properties, java.util.List<java.lang.String> commands, java.util.Map<java.lang.String,?> env)
ShellTool
ShellTool.execScript(Map, List, Map)
),
but is not suitable if you need env values which are only set on a fully-fledged shell,
or if you want the entire block executed with root permission.
Common optional properties (which also apply to ShellTool.execScript(Map, List, Map)
) are:
ShellTool.PROP_OUT_STREAM
ShellTool.PROP_ERR_STREAM
ShellTool.PROP_SEPARATOR
(for some modes)
ShellTool.PROP_NO_EXTRA_OUTPUT
(often there is no extra output here)
ShellTool.PROP_RUN_AS_ROOT
is not typically supported here. Prefer ShellTool.execScript(Map, List, Map)
).execCommands
in interface ShellTool
SshException
- If failed to connect#execCommands(Map, List, Map)}
int execCommands(java.util.Map<java.lang.String,?> properties, java.util.List<java.lang.String> commands)
execCommands
in interface ShellTool
execCommands(Map, List, Map)
int copyToServer(java.util.Map<java.lang.String,?> props, java.io.File localFile, java.lang.String pathAndFileOnRemoteServer)
The file will not preserve the permission of last _access_ date. Optional properties are:
PROP_PERMISSIONS
PROP_LAST_MODIFICATION_DATE
; not supported by all SshTool implementations
PROP_LAST_ACCESS_DATE
; not supported by all SshTool implementations
int copyToServer(java.util.Map<java.lang.String,?> props, java.io.InputStream contents, java.lang.String pathAndFileOnRemoteServer)
KnownSizeInputStream
for efficiency when the size of the stream is known.copyToServer(Map, File, String)
int copyToServer(java.util.Map<java.lang.String,?> props, byte[] contents, java.lang.String pathAndFileOnRemoteServer)
copyToServer(Map, File, String)
int copyFromServer(java.util.Map<java.lang.String,?> props, java.lang.String pathAndFileOnRemoteServer, java.io.File local)