How can I run Remote Commands via SSH?
RunBox Tools can be executed on distributed servers using SSH, a utility that is widely supported on UNIX and Linux platforms. There are three simple steps to set up a RunBox Tool based on SSH:
- Identify the account of the distributed server(s) that will be used for running the remote commands
- Configure the Credentials in RunBox
- Configure the Tool itself and associate the tool with the relevant credentials
Read on for information on these steps, plus ideas on how to enhance the flexibility of RunBox Tools with parameters.
Identify the SSH Account
Although the root user may be used for SSH connections to UNIX/Linux distributed servers it is suggested that a dedicated user is configured for such management tasks. This may be necessary to comply with company security policies. Most enterprise companies have a user management tool to assist with the user configuration.
Configure the RunBox Credentials
RunBox Credentials define how SSP may authenticate with a distributed server when establishing an SSH connection to execute a RunBox Tool. The definition inludes a user name and may apply to a single server or a group of servers.
Authentication for a specified user may either be via a password or a public key. For public key authentication RunBox will generate and display the required public key, as demonstrated in Figure 3. This key must be added to the file “<UserHomePath>/.ssh/authorization_keys” on the target servers. Note the “Copy to clipboard” button in figure 3 that can assist with this update. The directory “.ssh” and the file “authorization_keys” may need to be created.
Configure the RunBox Tool
RunBox Tools can execute any non-interactive system command, binary or script, for example a Perl or Shell script. User defined “interpreters” identify the interpreters for a specific script type. The example Tool in figure 4 is configured to run a “Perl” script on the selected “Target” via “SSH” authenticating as the user “orbsshu”. The tool is assigned to a Toolbox from the Toolboxes tab. It is the Toolboxes association with a Project that identifies the operators that will have access to the new tool and the potential targets.
When executed, this example tool will collect the disk usage for the mounted file systems on the selected servers, Figure 4 illustrates the execution of a file system usage tool on a single server. In this case the file system with the least available space is displayed in the summary in the central frame. The right-hand frame displays more details from the execution, including up to 5 lines from the script standard output. There is also a link to view the full output from the script. The link will open a new window.
Making RunBox Tools more flexible
To maximise the flexibility of the RunBox Tools the operator may be prompted for one or more parameters when executing the Tool, for example a log file name. The value entered by the operator can be used to affect the behaviour of the Tool, for example display the last ten lines of the specified log file name.
To create a tool that prompts for operator input at runtime firstly create a Parameter. The parameter configuration includes a unique name, a data type and optionally validation information, for example “not blank” or a regular expression.
The parameter is assigned to the Tool during the Tool configuration (on the Parameters tab). Variables representing the parameter runtime values may then be added as arguments on the Script tab.
These Tools can be assigned to the relevant operators empowering them to execute necessary tasks efficiently and securely.