When you are sitting in front of your Mac running the Software Update Syetem Preference Pane is a snap. What if you want to update a machine down the hall, across town, or on the other side of the Earth? Apple has a command line utility to do just that: softwareupdate.
Preparing the Remote Machine
The remote machine has to be accessible via the (inter)net. You must know its domain name (i.e. www.hmug.org) or IP address (i.e. 10.0.1.25). Knowing where the machine's address is not enough: we need to send commands to it. Enter the secure shell, ssh. To talk to a remote machine using ssh you need to remote machine to run a server process (sshd, the secure shell daemon). You enable sshd using the Remote Login checkbox in the Services tab of the Sharing System Preference Pane, see figure below.
Logging Into the Remote Machine
We first need to open the Terminal (/Applications/Utilities/Terminal). The we type either
ssh remote.machine.address or ssh firstname.lastname@example.org
The first time you log on to the remote machine, it will ask you if you trust the cryptographic key. Type in yes and hit the Return key.
The authenticity of host 'titan (10.0.1.50)' can't be established. RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'titan,10.0.1.50' (RSA) to the list of known hosts.
The machine then will ask you for your password. Type it in and hit the Return key. You should now be logged in.
Checking for Uninstalled Updates
We first want to check if there are any software update available. We can run softwareupdate without authentication (Note: the -l [list] is only required when using Panther - Mac OS X 10.3.x):
$ softwareupdate -l Software Update Tool Copyright 2002 Apple Computer, Inc. Software Update found the following new or updated software: - AirPortSW-2.1.1 AirPort Software (2.1.1), 4350K - restart required - iPod-1.2.6 iPod Software (1.2.6), 5772K To install an update, run this tool with the item name as an argument. e.g. 'softwareupdate <item> ...'
To install we have to authenticate using sudo:
$ sudo bash
We can now install either or both the updates we found. Note we can install as many updates as softwareupdate finds. To install the iPod update only type (Note: the -i [install] is only required when using Panther - Mac OS X 10.3.x):
# softwareupdate -i iPod-1.2.6
After softwareupdate finishes downloading and installing it will take some time to optimize your system (actually it pre-binds your libraries). You are now done. However, if you were to install the other update, or both updates, you will have an additional step: you need to restart your computer.
Remotely Restarting the Computer
Fortunately Mac OS X gives us the standard tool for shuting down and restarting a computer: reboot. Since often reboot is not in the default path, type:
to restart the computer. Note: it is wise to first check if there are any other users logged in. We can use the w command to do this:
# w 7:50PM up 22:39, 4 users, load averages: 1.79, 1.55, 1.45 USER TTY FROM LOGIN@ IDLE WHAT marius co - Thu09PM 22:39 - marius p1 - Thu09PM 0 -
Version 1.3.0 - 20070304