Executing commands on remote hosts with ssh

Tags:

Perhaps the most common use of ssh is to obtain a command prompt on a remote host. However, ssh also enables commands to be executed on remote hosts. Here are a couple of uses I find for this feature.

-----

1. Print a postscript file to a printer on a remote machine. There certainly are other more common ways to do remote printing, but this option only requires a printer to be set up for local printing from a single host. For example, if you have a Windows-only printer, it is possible to print to it from a Linux machine! First you need to install Cygwin and ssh on the Windows machine. Then follow the instructions here for setting up a ghostscript printer on Windows. Then you can print to the Windows printer with the following script:

#!/bin/sh

scp $1 windows_host:tmp.ps
ssh aurelia 'cat tmp.ps > //windows_host/GS'

where windows_host is the name of your windows machine. If the script is named PrintToWindows, then to print a postscript file, simply execute

$ PrintToWindows file.ps

-----

2. Run an application installed on another machine remotely. For example, lets say you have an old laptop and Firefox is very slow to load, or is not installed at all. No matter. You can configure a launcher in your favorite desktop environment to run
"ssh faster_host firefox". Presto-- you are no longer browsing at the speed of molasses.

-----

Of course, this feature is most convenient if you use ssh-keygen for password-less authentication. However, XFCE (and possibly other desktop environments) will prompt you for your password if you have not set up password-less authentication.

0
Syndicate content