Filed under: Cool tools, Open Source
dsh: dancer's shell gives you power over multiple Macs
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.

![TUAW [Cafepress]](http://www.blogsmithmedia.com/www.tuaw.com/media/tuaw-cafepress-promo.png)


Reader Comments (Page 1 of 1)
Aaron Davies said 2:35PM on 1-11-2008
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
Michael Rose said 2:39PM on 1-11-2008
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).
jadam said 3:22PM on 1-11-2008
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
Fabio said 4:13PM on 1-11-2008
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
SireB said 4:15PM on 1-11-2008
What is the port name? 'sudo install port dsh' doesn't seem to work
Reply
Michael Rose said 4:32PM on 1-11-2008
Sire, I said it's NOT in Macports. Sorry, you'll need to compile from source... :-)
Michel said 6:19PM on 1-11-2008
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
Josh said 9:39PM on 1-11-2008
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
James said 12:58AM on 1-12-2008
There is also pdsh, for running it in parallel
Reply
artifex said 3:27AM on 1-12-2008
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
artifex said 3:28AM on 1-12-2008
oh, hah: "Fink Is Not Kaput ;)"
http://www.racoonfink.com/archives/000752.html
mzsanford said 11:54AM on 1-14-2008
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