From 2a8452347612524e4807fc8ed3f4b39e7b490cdb Mon Sep 17 00:00:00 2001 From: Flavio Poletti Date: Mon, 8 Feb 2010 12:28:41 +0100 Subject: [PATCH] Slight fixes for password handling. --- deploy | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/deploy b/deploy index 3f28bdb..7fd3a2d 100755 --- a/deploy +++ b/deploy @@ -51,8 +51,12 @@ pod2usage(-verbose => 99, -sections => 'USAGE', my @hostnames = @ARGV; @ARGV = (); -$config{password} = prompt 'password: ', -e => '*' - unless exists $config{password}; +if (exists $config{password}) { + $config{interactive} = 1; + $config{identity_files} = []; + $config{password} = prompt 'password: ', -e => '*' + unless $config{password}; +} ($config{remote} = $config{script}) =~ s{[^\w.-]}{}mxsg; $config{remote} = catfile($config{dir}, $config{remote}); @@ -120,12 +124,19 @@ sub make_path { return; } ## end sub make_path +sub _get_optionals { + map { $_ => $config{$_} } grep { exists $config{$_} } qw( interactive identity_files password ); +} + sub get_ssh { my ($hostname) = @_; + my %optional; + my $ssh = Net::SSH::Perl->new( $hostname, protocol => 2, debug => $config{debug}, + _get_optionals(), ); $ssh->login($config{username}, $config{password}, 'suppress_shell'); @@ -143,6 +154,8 @@ sub get_sftp { protocol => 2, debug => $config{debug}, compression => $config{compress}, + user => $config{username}, + _get_optionals(), } ); } ## end sub get_sftp @@ -200,7 +213,8 @@ key authentication in favour of username/password authentication. Don't ask me why, this may change in the future. Anyway, you're not obliged to provide either on the command line: the username defaults to C, and you'll be prompted to provide a password if you don't put any -on the command line. The prompt does not show the password on the terminal. +on the command line but specify the C<--password|-p> option without a value. +The prompt does not show the password on the terminal. By default, L will try to use public/private key authentication. If you're confident that this method will work, you can -- 2.11.4.GIT