Skip Menu |

This queue is for tickets about the Net-SCP-Expect CPAN distribution.

Report information
The Basics
Id: 38081
Status: resolved
Priority: 0/
Queue: Net-SCP-Expect

People
Owner: RYBSKEJ [...] cpan.org
Requestors: jgoulah [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: scp fails without a password supplied (patch included)
Net::SCP::Expect does not work correctly if no password is supplied (ie. only want to authenticate with keys). Because some are using two-factor authentication I've supplied a patch with an option called 'nopassword' to allow key authentication only.
Subject: net-scp-expect.patch
--- Expect.pm.orig 2008-07-31 14:51:16.000000000 -0500 +++ Expect.pm 2008-07-31 14:50:12.000000000 -0500 @@ -43,6 +43,7 @@ _subsystem => $arg{subsystem} || undef, _scp_path => $arg{scp_path} || undef, _auto_quote => $arg{auto_quote} || 1, + _nopassword => $arg{nopassword} || 0, }; bless($self,$class); @@ -129,6 +130,7 @@ my $subsystem = $self->_get('subsystem'); my $scp_path = $self->_get('scp_path'); my $auto_quote = $self->_get('auto_quote'); + my $nopassword = $self->_get('nopassword'); ################################################################## # If the second argument is not provided, the remote file will be @@ -153,7 +155,8 @@ } croak("No login. Can't scp") unless $login; - croak("No password. Can't scp") unless $password; + croak("No password. Can't scp (Consider 'nopassword' option)") unless $password || $nopassword; + croak("Cant set nopassword without identify file") if $nopassword && !$identity_file; croak("No host specified. Can't scp") unless $host; # Define argument auto-quote @@ -202,22 +205,24 @@ } } - unless($scp->expect($timeout,-re=>'[Pp]assword.*?:|[Pp]assphrase.*?:')){ - my $err = $scp->before() || $scp->match(); - if($err){ + if (!$nopassword) { + unless($scp->expect($timeout,-re=>'[Pp]assword.*?:|[Pp]assphrase.*?:')){ + my $err = $scp->before() || $scp->match(); + if($err){ + if($handler){ $handler->($err); return; } + else { croak("Problem performing scp: $err"); } + } + $err = "scp timed out while trying to connect to $host"; if($handler){ $handler->($err); return; } - else { croak("Problem performing scp: $err"); } + else{ croak($err) }; } - $err = "scp timed out while trying to connect to $host"; - if($handler){ $handler->($err); return; } - else{ croak($err) }; - } - if($verbose){ print $scp->before() } + if($verbose){ print $scp->before() } - $password .= $terminator if $terminator; + $password .= $terminator if $terminator; - $scp->send($password); + $scp->send($password); + } ################################################################ # Check to see if we sent the correct password, or if we got @@ -497,6 +502,9 @@ this disables some error checking (ala no_check) because the verbose output could otherwise be picked up by expect itself. +B<nopassword> - Set to 1 if you would like to use the identity file without +a password supplied + =head1 NOTES The -q option (disable progress meter) is automatically passed to scp.
I've chosen to take a simpler approach by eliminating the password requirement if an identity file is specified. I've updated POD regarding password usage to clarify these usage modifications. Change included in 0.14 release.