diff --git a/README.md b/README.md index 8a83ca5..6d1ac8b 100644 --- a/README.md +++ b/README.md @@ -239,3 +239,4 @@ Troubleshooting (Ubuntu12.04LTS or higher version) - [Ganesh Nalawade](https://github.com/ganeshnalawade) - [Priyal Jain](https://github.com/Jainpriyal) + - [Ruairi Carroll](https://github.com/rucarrol) diff --git a/lib/Net/Netconf/Access/ssh.pm b/lib/Net/Netconf/Access/ssh.pm index f9ae399..41c8b8b 100644 --- a/lib/Net/Netconf/Access/ssh.pm +++ b/lib/Net/Netconf/Access/ssh.pm @@ -43,11 +43,23 @@ sub start } # This implementation assumes OpenSSH. - my $command = $echostate . $sshprog . ' -l ' . - $self->{'login'} . ' -p ' . $rport . - ' -s ' . $self->{'hostname'} . + + ## Lets try get some ssh key auth going + our $command; + if ( defined( $self->{'keyfile'} ) ) { + $command = $echostate . $sshprog . ' -l ' . + $self->{'login'} . ' -p ' . $rport . + ' -i ' . $self->{'keyfile'} . + ' -s ' . $self->{'hostname'} . ' ' . $self->{'server'}; + } + else { + $command = $echostate . $sshprog . ' -l ' . + $self->{'login'} . ' -p ' . $rport . + ' -s ' . $self->{'hostname'} . + ' ' . $self->{'server'}; + } # take expect object from user ow build your own if (defined $self->{'exp_obj'}){ diff --git a/lib/Net/Netconf/Device.pm b/lib/Net/Netconf/Device.pm index e908572..ee5c623 100755 --- a/lib/Net/Netconf/Device.pm +++ b/lib/Net/Netconf/Device.pm @@ -116,10 +116,19 @@ sub new my ($class, %args) = @_; my $self = { %args }; - # Make sure we have 'login', 'hostname' and 'password' + # Make sure we have 'login', 'hostname' and 'password'. Dont need password if keyfile is set. croak 'missing information ' unless exists $args{'hostname'}; croak 'missing information ' unless exists $args{'login'}; - croak 'missing information ' unless exists $args{'password'}; + + ## Only die if password is unset and keyfile is unset... + if (!defined($args{'keyfile'})) { croak 'missing information ' unless exists $args{'password'} ; } + + ## Only die if keyfile is unset and password is unset... + if (!defined($args{'password'})) { croak 'missing information ' unless exists $args{'keyfile'} ; } + + ## check to see if the keyfile actually exists + if (!defined($args{'password'})) { croak ' not found in specified location' unless (-e $args{'keyfile'}); } + # SAX Parser my $handler = new Net::Netconf::SAXHandler('ErrorContext' => 5); diff --git a/lib/Net/Netconf/Manager.pm b/lib/Net/Netconf/Manager.pm index e5970ab..ca5bfc1 100644 --- a/lib/Net/Netconf/Manager.pm +++ b/lib/Net/Netconf/Manager.pm @@ -67,6 +67,7 @@ It also does error handling. 'hostname' => 'routername', 'login' => 'loginname', 'password' => 'secret', + 'keyfile' => 'keyfile', 'access' => 'ssh', 'server' => 'netconf', 'command' => 'junoscript netconf',