This recipe shows you how to execute one-shot commands on a remote system through Secure Shell (SSH). Having the ability to run commands without establishing a full interactive session can be convenient because you can avoid running a second terminal; everything can be done directly from the same command line.
This recipe requires a remote system running the OpenSSH server and a local computer with the OpenSSH SSH client installed (both should be installed by default on CentOS). The examples assume that the remote system is configured with the IP address 192.168.56.100
. Also, you will need a user account available on the remote system.
The following examples show you how to run commands on a remote system from your local system through SSH:
To execute a command remotely, use
ssh
and specify the hostname or IP address of the target system followed by the command and its arguments:ssh 192.168.56.100 uname -a
To execute the command...