In the following post I will demonstrate a password-less login into Cisco appliance via the SSH protocol using a Perl script.
When combined with cron, it can be a great solution for saving your appliance configuration (show run) or checking status without the need to log-in into the appliance each time.
- SSH client (duh!)
- Net-SSH-Perl module
On Red-Hat (and friends) the module can be obtained via:
#yum install perl-Net-SSH-Perl -y
Be sure to have a proper repository installed such as rpmforge
The script itself should look like this:
my $ssh = Net::SSH::Perl->new('hostname');
my($out) = $ssh->cmd("show run");
Since the script contains your appliance username & password don't forget to remove permissions for others:#chmod o-rwx script.pl
Now, let's run the script:
Current configuration : 8011 bytes
...more output ommited...
Works like charm!
Now, the only thing is left is to synchronize it with cron :)