<?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>ServerAdmins.NET &#187; login</title>
	<atom:link href="http://serveradmins.net/tag/login/feed/" rel="self" type="application/rss+xml" />
	<link>http://serveradmins.net</link>
	<description>Stuff for Server Admins...</description>
	<lastBuildDate>Fri, 09 Jul 2010 16:46:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Systems Administration with Perl and SSH</title>
		<link>http://serveradmins.net/systems-administration-with-perl-and-ssh/</link>
		<comments>http://serveradmins.net/systems-administration-with-perl-and-ssh/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 23:54:10 +0000</pubDate>
		<dc:creator>chrism</dc:creator>
				<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Utility]]></category>
		<category><![CDATA[administration]]></category>
		<category><![CDATA[login]]></category>
		<category><![CDATA[Net::SSH::Perl]]></category>
		<category><![CDATA[Perl]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[systems]]></category>

		<guid isPermaLink="false">http://serveradmins.net/?p=45</guid>
		<description><![CDATA[ How to write a basic connection script using Perl's Net::SSH::Perl module.]]></description>
			<content:encoded><![CDATA[<p>Hey there!</p>
<p>Today I wanted to focus on something that&#8217;s helping me do my job in a more efficient fashion.  At a former workplace, I was responsible for ~200 high capacity webhosting machines, and a host of supporting machines.   Back then, I was a huge fan of a management system mostly comprised of SSH Keys and a ton of bash scripts.   It worked, quite well for the time, but if I could do it again, I&#8217;d go with a slightly more refined approach, which is what we&#8217;ll discuss today.</p>
<p>So, let&#8217;s get started.   The first thing you&#8217;ll need is a working perl installation, a few devel libs and a handful of perl modules.  </p>
<p><code> yum install gmp-devel</code><br />
<code>perl -MCPAN -e 'install Crypt::DH , Math::GMP,  Net::SSH::Perl'</code></p>
<p>This is going to install the GMP math development libraries necessary for Math::GMP to compile.   Math::GMP and Crypt::DH are prereqs for Net::SSH::Perl.</p>
<p>So once this is done, we can proceed. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><code><br />
#!/usr/local/bin/perl -w</p>
<p>use strict;<br />
use warnings;<br />
require Net::SSH::Perl;</p>
<p>#declare our login vars...</p>
<p>my $user = "root";<br />
my $password = "SEKUREPASSWORD";<br />
my $server = "localhost";</p>
<p>#Setup our SSH Connection...<br />
my $ssh = Net::SSH::Perl->new($server,port=>22,use_pty=>1);</p>
<p>#Initiate out conneciton to the server...<br />
$ssh->login($user, $password);</p>
<p># Declare our variable for the request...<br />
my $uptime;</p>
<p># Run our SSH Command and retrieve the output...<br />
($uptime) = $ssh->cmd("/usr/bin/uptime");</p>
<p>print "\n$uptime\n";</p>
<p>exit 0; </p>
<p></code></p>
<p>That&#8217;s a very basic/barebones SSH Connection script&#8230;   If you have any questions or problems, please don&#8217;t hesitate to post in the comments. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />   </p>
<p>Next up, we&#8217;ll go over a more complex variant of this script using subroutines and a few other nifty tricks. <img src='http://serveradmins.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://serveradmins.net/systems-administration-with-perl-and-ssh/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->