O'Reilly logo

Linux Shell Scripting Cookbook by Sarath Lakshman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Running commands on remote host with SSH

SSH is an interesting system administration tool that enables to control remote hosts by login with a shell. SSH stands for Secure Shell. Commands can be executed on the shell received by login to remote host as if we run commands on localhost. It runs the network data transfer over an encrypted tunnel. This recipe will introduce different ways in which commands can be executed on the remote host.

Getting ready

SSH doesn't come by default with all GNU/Linux distributions. Therefore, you may have to install the openssh-server and openssh-client packages using a package manager. SSH service runs by default on port number 22.

How to do it...

To connect to a remote host with the SSH server running, use:

$ ssh username@remote_host ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required