This month's MacTech magazine offers a feature article by Edward Marczak on using dsh, the "dancer's shell" or distributed shell utility, to batch-administer machines in a single blast without having to hit each one, or use a pricey management tool such as ARD or LANrev. Although dsh isn't included with Mac OS X or available as a binary or port build, it does compile cleanly on the Mac and should work well out of the box.The idea behind dsh is to take a list of targets (machines you can reach via SSH), and run a command or extended script on all of them at once. This is functionality that's wrapped up in a nice GUI in Apple Remote Desktop; it's deeply powerful and very handy. Supposing you wanted to check the uptime for a bunch of your lab boxes -- manually, you'd have to run around, or SSH to each one and run the 'uptime' command. With dsh, you make your machine list (optionally, loading your SSH public key on the machines ahead of time to avoid password prompts) and run one command:
dsh -Ma uptimeVery handy. The full article isn't online yet, but it's worth seeking out a copy of the magazine if you're interested in automation of enterprise Mac admin tasks.













Reader Comments (Page 1 of 1)
1-11-2008 @ 2:35PM
Aaron Davies said...
Interesting. I have a primitive version myself, basically just a wrapper on "for host in ...; do ssh $host $*; done". I called it "blast". I'll have to give this a try.
Reply
1-11-2008 @ 2:39PM
Michael Rose said...
Let us know how it goes. Interesting challenge is doing tasks that require admin access on the remote host, as it's hard to pass a sudo password through (at least it was for me).
1-11-2008 @ 3:22PM
jadam said...
I used dsh a lot when I was administering a beowulf cluster. Glad to hear that it's working on the Mac. Here's a quick tip: set up a public/private keypair within ssh for the user you're planning to use, and make sure you can ssh over with no password prompt before trying to use dsh. Typing the password over and over again is no fun.
Reply
1-11-2008 @ 4:13PM
Fabio said...
Well, cool idea. "But" we've been doing that already for some time thanks to the Ruby on Rails deployment tool "Capistrano". One of its feature is exactly a command line "cap shell" that allows us to run shell commands in multiple machines (and check its output). It also uses ssh, by the way.
Reply
1-11-2008 @ 4:15PM
SireB said...
What is the port name? 'sudo install port dsh' doesn't seem to work
Reply
1-11-2008 @ 4:32PM
Michael Rose said...
Sire, I said it's NOT in Macports. Sorry, you'll need to compile from source... :-)
1-11-2008 @ 6:19PM
Michel said...
I made a kind of similar tool at my work on my mac (and linux of course)
it uses texts lists but also LDAP to get list of computers to ssh-execute the command.
for example, I can ask "all machines in the room 305" and it uses ldap to know what are the ip of the computer in the 305 room.
I made also little scripts and a website (for admins colleagues) to manage my custom directory of computers.
Reply
1-11-2008 @ 9:39PM
Josh said...
yeah I built a very robust perl script that does this with many very nice options about 2.5 years ago. I update it and add features frequently so it's become quite a nice tool.
This is a definite need for many admins tho so kudos!
Reply
1-12-2008 @ 12:58AM
James said...
There is also pdsh, for running it in parallel
Reply
1-12-2008 @ 3:27AM
artifex said...
I was going to suggest looking to see if fink has a package, but oops, looks like Godaddy's parked the domain name now. sad :(
Reply
1-12-2008 @ 3:28AM
artifex said...
oh, hah: "Fink Is Not Kaput ;)"
http://www.racoonfink.com/archives/000752.html
1-14-2008 @ 11:54AM
mzsanford said...
There is a feature in iTerm that lets you send commands to multiple windows. I like it because I can chain a tail -f of the log after the command and check each host to make sure nothing went wonkey.
Reply