ssh-exec [ -b ] -u user@hostname < commands
ssh-exec [ -b ] -u user -t hostname < commands
ssh-exec -p [ -e | -l localuser ] -u user@hostname
ssh-exec -p [ -e | -l localuser ] -u user -t hostname
ssh-exec [ -s | -v ][ -n ][ -b ][ -e | -l localuser ] -u user@hostname < commands
ssh-exec [ -s | -v ][ -n ][ -b ][ -e | -l localuser ] -u user -t hostname < commands
Prior to the remote command invocation it is checked if the remote target system with hostname is up and if it is possible to connect using the provided user to the remote target system.
In addition to the commands it is supported to submit answers to specific outputs (when it is not possible to do it using simple input redirection) or an except(3) script without the need to write extra "wrapper" scripts.
Simple command invocation on a target system:
ssh-exec -u user@target <<EOM ps -ef | grep oracle EOM
or
ssh-exec -u user@target <<EOM [COMMANDS] ps -ef | grep oracle EOM
The [COMMANDS] section keyword is optional as long as it is the first section provided to ssh-exec.
Command invocation with input redirection of needed command inputs:
ssh-exec -u user@target <<EOM restore-data <<EOI /dat/backup/acme-001/2020-01-10/etc/hosts /etc/hosts EOI EOM
Remote control an interactive command that reads the input from a tty and not from stdin:
ssh-exec -u user@target <<EOM [COMMANDS] set-license-key [ANSWERS] ;Input new license key:;VcB542RSXtMZM\r; ;Repeat new license key:;VcB542RSXtMZM\r; EOM
Behind the scenes the provided answers in the [ANSWERS] section are translated automatically into an ad-hoc expect script, as:
expect "Input new license key:" send -- "VcB542RSXtMZM\r" expect "Repeat new license key:" send -- "VcB542RSXtMZM\r" expect eof
that is used to remote control the command.
This helps to efficiently handle the most cases of remote command control where the needed expect definition would be a expect ... -> send -- ... sequence.
The [ANSWERS] section has the format:
where the first character is treated as separator between the Input prompt and the Answer fields.
Therefore, if the Input prompt or the Answer contains the field separator character (the colon : in this example) the specification
is identical to the specification above.
Remote control an interactive command that reads the input from a tty and not from stdin.
The expect script has to be provided only if the automatically generated script using the [ANSWERS] section is not sufficient to the needs to control a command.
ssh-exec -u user@target <<EOM [COMMANDS] set-license-key [EXPECT] expect "Input new license key:" send -- "VcB542RSXtMZM\r" expect "Repeat new license key:" send -- "VcB542RSXtMZM\r" expect eof EOM
When -e is used or the EDRC_USER (default=edrc) is used in the -l localuser option, the private keys as defined in var/connection/security/edrc/OpenSSH/default/default/id_dsa and var/connection/security/edrc/OpenSSH/default/default/id_rsa are used to connect to the remote hostname.
Prerequisite to a working connection is that the contents of the files var/connection/security/edrc/OpenSSH/default/default/id_dsa.pub and var/connection/security/edrc/OpenSSH/default/default/id_rsa.pub are appended to the ~user/.ssh/authorized_keys file on the target hostname.
To efficiently add the public keys to authorized_keys files on hosts where the WA2L/edrc package is installed, use the ssh-keyadd(1m) command.
When using this option the private SSH keys of the specified localuser (as defined in ~localuser/.ssh/id_dsa and ~localuser/.ssh/id_rsa files) on the local system are used to connect to the target hostname.
See -e option description for additional information.
Commands can be read from file using the input redirection:
ssh-exec options < commands
providing the file contents thru the pipe:
cat commands | ssh-exec options
or the 'in here' mechanism in scripts without the creation of an extra file:
ssh-exec options <<EOM command_1 command_2 command_n EOM
To poll a list of systems for reporting data most efficiently, use the syspoll(1) command.
This is free software; see edrc/doc/COPYING for copying conditions. There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.