Monday, 23 February 2015

Execute commands on a remote Linux machine

We know that ssh is used to remote login to a server. But did you know that we can use ssh to execute command or script on a remote system. This is the syntax how we can do it:

ssh [USER]@[IP] [command or script]


Let us look at how this can be done. Suppose you want to display the directory contents of /root of a remote host, you can run the following command:

ssh root@192.168.1.79 ls -l

N.B. - It will ask for the password.

In the same way you can execute any script on the remote machine.


No comments:

Post a Comment