Author : Shawn Flynn

Scripting remote execution with SSH

Today, while doing some maintenance on my MythTV master backend, I rebooted it, but forgot to restart the backend services on my slave backends. Of course this meant that I missed some recordings. This started me thinking about how I could automate the process of restarting the remote backend processes whenever I started the master backend process. The solution was to configure ssh to authenticate between the machines using a public/private keypair, rather than using password authentication. I could then write a script that would ssh to the slave machines and restart their mythbackend services.

Setting up the ssh authentication is simple. Let’s say I want to run a script from a machine named mythmbe and have it execute a command using the username mythtv on the remote machine named mythbe1

First, generate a private/public keypair using ssh-keygen, which will be stored in ~/.ssh

$ ssh-keygen -t dsa

Now copy the public key to every remote machine you want to ssh in to without supplying a password…

$ scp ~/.ssh/ mythtv@mythbe1:~mythtv/.ssh/authorized_keys

You can now log in to the remote machine with ssh without needing to supply a password. The public key you copied to the remote machine will be tested against your private key to verify your identity whenever you try to connect. To test this, try something like…

$ ssh mythbe1 /sbin/service mythbackend restart

Automatic Updates acting up again…

Once more I find that one of my Windows 2000 boxen has decided it no longer likes Windows Update Service and is spewing the following error into the application eventlog every 10 minutes.

Event Source: ESENT
Event ID: 427
Description: wuaueng.dll (1588) The database engine could not access the file called C:\WINNT\SoftwareDistribution\DataStore\Logs\edb.log.

The fix is pretty straight forward. Simply stop the ‘Automatic Update’ service on the affected machine, delete the %windir%\SoftwareDistribution\DataStore\Logs\edb.log file, then restart the service. The log file will be recreated the next time Automatic Updates checks in with the WSUS server and the eventlog error will be gone.


Welcome to my little home on the web. Here you will find all manner of random ramblings on things that have interested or intrigued me. Mostly hints/fixes for some technical bug that has been pestering me, and I’m sure I’ll forget how to fix the next time if I don’t write it down somewhere. Hopefully some of these will help some other poor soul out there. Enjoy 🙂