Simple SSH Authentication
3 05 2008I write a simple program for SSH authentication, just simple…cause i’m just learning step by step for network programming. Nice package module from Christian Hansen.
====================================================================================
#!/usr/bin/perl
use strict;
use warnings;
use Authen::Simple::SSH;
if ($#ARGV != 2){
print “Usage : $! host username password”;
exit;
}
my $host = $ARGV[0];
my $uname = $ARGV[1];
my $passwd =$ARGV[2];
my $ssh = Authen::Simple::SSH -> new (host => $host);
die “Can’t locate to target” unless $ssh;
if ($ssh->authenticate($uname,$password))
{
print “Authentication is sucessfull”;
}
else {
print “Failed to connect, username or password is wrong”;
}
====================================================================================
Keep learning.






Recent Comments