This is a great method to execute commands on a remote server without actually opening another window and running the command directly. Additionally, if you have a server monitor setup this is a great way to restart services if a service crashes. We often use this method on internal servers and when a service outage is triggered the primary monitor will execute a command automatically.
Example:
Our monitor checks the sendmail service every 5 minutes. If the service is down most monitors simply notify a technician. However, with the usage of SSH keys we’re able to execute a command on the monitor server automatically to restart the service:
ssh -l root -o “BatchMode yes” host.hostname.com “/etc/init.d/sendmail restart”
The command above tells the monitor server to connect to host.hostname.com and then restart sendmail. This can be used to automatically restart any service.