Anyway, there are few other ways to do it. Make sure you know one of them.

Today, I'm given a task to write a Perl script to scan 200 servers' Interwoven, EPA, JVM and web server configurations. Normally, I'd like to use shell script to do anything related to SSH. However, with so many text files to scan why don't we use Perl to do it?

Perl SSH? Google over the Internet (thanks for the US for not censoring Google's searching result), it appears Net::SSH::Perl is a good but tough candidate. Most reviews complain about the painful installation process which makes it a challenge to me. I like pain, right? (not really)

Now, let's see what is Net::SSH::Perl.

"Net::SSH::Perl is an all-Perl module implementing an SSH client. It is compatible with both the SSH1 and SSH2 protocols.

Net::SSH::Perl enables you to simply and securely execute commands on remote machines, and receive the STDOUT, STDERR, and exit status of that remote command."

Good enough. Let's do it. (For more information about Net::SSH::Perl, see CPAN).

Installation of Net::SSH::Perl is really painful if your system doesn't have the required Math packages.

For cygwin, as of today (March 25,2010), because Perl 5.10.1 is compiled with gcc 4.3.4 (20090804) while gcc for cygwin is only at 3.4.4, the -fstack-protector gcc flags kills you. I tried to force install the module, it always stop at complaining the -fstack-protector flag when running perl script calling SSH module.

You have to recompile gcc in cygwin in order to use this module. To compile gcc, you need m4, Math::Pari, GMP, MFPR... OK, just kill me. I'm giving up.

Luckily, we have Ubuntu. With the pleasant apt-get utility, installation is much better than cygwin.

Installing Net::SSH::Perl module on Linux server (Ubuntu 9.x)

I'm using a dirty quick solution, first, let's cpan the module with force; then, we clean up the mess. Don't try it on production systems.

1. Force install Net::SSH::Perl

cpan> force install Net::SSH::Perl

2. Clean up work. Let's see the error messages at the end of installation and re-install these packages manually.

For GMP, because it was never installed, download it from http://gmplib.org/.However, before we install GMP, we need to install m4...To Install m4, we need to install (nothing)... there's always a clue that leads to another clue before you can find the treasure.

sudo apt-get install m4

download gmp from http://gmplib.org/ and compile/install it

Now, we need to check what Perl modules are installed on our server: (yes, another good interview question).