<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Racker Hacker &#187; dsh</title>
	<atom:link href="http://rackerhacker.com/tag/dsh/feed/" rel="self" type="application/rss+xml" />
	<link>http://rackerhacker.com</link>
	<description>Words of wisdom from a server administrator</description>
	<lastBuildDate>Wed, 16 May 2012 12:55:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Crash course in dsh</title>
		<link>http://rackerhacker.com/2010/01/20/crash-course-in-dsh/</link>
		<comments>http://rackerhacker.com/2010/01/20/crash-course-in-dsh/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 14:47:56 +0000</pubDate>
		<dc:creator>Major Hayden</dc:creator>
				<category><![CDATA[Blog Posts]]></category>
		<category><![CDATA[command line]]></category>
		<category><![CDATA[dsh]]></category>
		<category><![CDATA[puppet]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[sysadmin]]></category>

		<guid isPermaLink="false">http://rackerhacker.com/?p=1133</guid>
		<description><![CDATA[Thanks to a recommendation from Michael and Florian, I've been using dsh with a lot of success for quite some time. In short, dsh is a small application which will allow you to run commands across many servers via ssh very quickly. You may be wondering: "Why not just use ssh in a for loop?" [...]<p><a href="http://rackerhacker.com/2010/01/20/crash-course-in-dsh/">Crash course in dsh</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></description>
			<content:encoded><![CDATA[<p>Thanks to a recommendation from <a href="http://twitter.com/mshuler">Michael</a> and <a href="http://twitter.com/pandemicsyn">Florian</a>, I've been using <a href="http://www.netfort.gr.jp/~dancer/software/dsh.html.en">dsh</a> with a lot of success for quite some time.  In short, dsh is a small application which will allow you to run commands across many servers via ssh very quickly.</p>
<p>You may be wondering: "Why not just use ssh in a for loop?"  Sure, you could do something like this in bash:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">for</span> i <span style="color: #000000; font-weight: bold;">in</span><span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">cat</span> ~<span style="color: #000000; font-weight: bold;">/</span>myhosts.txt<span style="color: #000000; font-weight: bold;">`</span>; <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #c20cb9; font-weight: bold;">ssh</span> <span style="color: #007800;">$i</span> <span style="color: #ff0000;">'uptime'</span>; <span style="color: #000000; font-weight: bold;">done</span></pre></div></div>

<p>But dsh allows you to do this:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">dsh -g myhosts 'uptime'</pre></div></div>

<p>In addition, dsh allows you to run the commands concurrently (-c) or one after the other (-w).  You can tell it to prepend each line with the machine's name (-M) or it can omit the machine name from the output (-H).  If you need to pass extra options, such as which ssh key to use, or an alternative port, you can do that as well (-o).  All of these command line options can be tossed into a configuration file if you have a default set of options you prefer.</p>
<p>Another thing that makes dsh more powerful is the groups feature.  Let's say you have three groups of servers - some are in California, others in Texas, and still others in New York.  You could make three files for the groups:</p>
<ul>
<li>~/.dsh/group/california</li>
<li>~/.dsh/group/texas</li>
<li>~/.dsh/group/newyork</li>
</ul>
<p>Inside each file, you just need to list the hosts one after the other.  Here's the <code>~/.dsh/group/texas</code> group file:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">db1.tx.mydomain.com
db2.tx.mydomain.com
web1.tx.mydomain.com
web2.tx.mydomain.com
#web3.tx.mydomain.com</pre></div></div>

<p>As you can see, dsh handles comments in the hosts file.  In the above example, the web3 server will be skipped since it's prepended with a comment.  Let's say you want to check the uptime on all of the Texas servers as fast as possible:</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">dsh -c -g texas 'uptime'</pre></div></div>

<p>That will run the <code>uptime</code> command on all of the servers in the Texas group concurrently.  If you need to run it on two groups at once, just pass another group (eg. <code>-g texas -g california</code>) as an argument.  You can also run the commands against all of your groups (-a).</p>
<p>The dsh command can really help you if you need to gather information or run simple commands on many remote servers.  If you find yourself using it often for systems management, you may want to consider something like <a href="http://reductivelabs.com/products/puppet/">puppet</a>.</p>
<p><a href="http://rackerhacker.com/2010/01/20/crash-course-in-dsh/">Crash course in dsh</a> is a post from: Major Hayden's <a href="http://rackerhacker.com">Racker Hacker</a> blog. 
<p>Thanks for following the blog via the RSS feed. Please don't copy my posts or quote portions of them without attribution.</p></p>
]]></content:encoded>
			<wfw:commentRss>http://rackerhacker.com/2010/01/20/crash-course-in-dsh/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

