Running SSH commands (remotely)

Consider a login on ta Host machine. To run a command (let us try a simple ls to list the current directory), just type:

ssh -X login@IPhostMachine ls

In practice, commands are longer and you would rather use double quotes around the command(s)

ssh -X login@IPhostMachine "cd temp; ls"

SSH logs you in the home directory (e.g., /home/login).

Then, you can type most of the unix commands. You need to be careful with single and double quotes.

Note also that to run a command in the background, you need this kind of syntax:

    ssh login@host "nohup myprogram > foo.out 2> foo.err < /dev/null &"

This simple one may not work:

    ssh login@host "myprogram &"

Indeed, backgrounded job can cause the shell to hang on logout.

Please follow and like us:
This entry was posted in Linux and tagged . Bookmark the permalink.

One Response to Running SSH commands (remotely)

Leave a Reply

Your email address will not be published.