gafaman has asked for the wisdom of the Perl Monks concerning the following question:
Could you please lend me some wisdom? Thanks! Gafaman#!/usr/bin/perl use strict; use warnings; use Net::SSH::Expect; print "Device IP: "; my $deviceIP = <STDIN>; chomp $deviceIP; my $user = "gafaman"; print "User password: "; my $pass = <STDIN>; chomp $pass; my $epass = "beholder"; my $login_timeout = 60; use POSIX qw(strftime); my $datestring = strftime "%F", localtime; my $ssh = Net::SSH::Expect->new( host => $deviceIP, user => $user, password => $pass, raw_pty => 1, no_terminal => 0, log_stdout => 1 ); $ssh->login(); #When the line below is executed, it ends with a "Password: " prompt $ssh->exec("cat \~\/\.ssh\/id_rsa.pub|ssh \'-o StrictHostKeyChecking=n +o\' bkpuser\@10.11.12.13 \'cat \>\> \.ssh\/authorized_keys \&\& echo +\"KeyCopied\"\'",2); $ssh->waitfor('Password:\s*', 5) or die "prompt 'Password' not found a +fter 5 seconds"; $ssh->send("$epass"); $ssh->close();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Send password in Net::SSH::Expect
by Fletch (Bishop) on Jan 21, 2020 at 15:11 UTC | |
by gafaman (Novice) on Jan 23, 2020 at 08:41 UTC | |
by gafaman (Novice) on Jan 23, 2020 at 08:51 UTC | |
by Corion (Patriarch) on Jan 23, 2020 at 09:03 UTC | |
by gafaman (Novice) on Jan 23, 2020 at 09:24 UTC | |
|