Thanks for all the great suggestions!
As requested, here is the relevant code (after some of the suggestions
+ implemented) and the output.
It appears that the pattern match isn't working, although I'm trying t
+o match anything, and again this is working on 2 other servers.
It also appears as if it's asking for authentication info, yet if i ma
+nually ssh it connects without user/password.
Thanks again for the help!
sub ssh_login {
my ( $remote_server, $username, $password ) = @_;
my $ssh = Net::SSH::Expect->new(
host => $remote_server,
password => $password,
user => $username,
raw_pty => 0,
#no_terminal => 1,
#port => $port,
timeout=>10,
#terminator=>"\r\n",
log_file => '/tmp/test_ssh.log',
exp_debug =>1,
exp_internal =>1,
);
# 2) logon to the SSH server using those credentials.
# test the login output to make sure we had success
my $login_output = $ssh->login();
if ( $login_output !~ /.*/ ) {
#$logger->error("$0:Login has failed. Login output was $login_
+output");
print "$0:Login has failed. Login output was $login_output" .
+"\n";
}
$ssh->exec("stty raw -echo");
return $ssh;
}
Spawned 'ssh -e none user@****-idx-dev3.****.****.com'
spawn id(5)
Pid: 3237
Tty: /dev/ttys007
at /System/Library/Perl/Extras/5.10.0/Expect.pm line 181.
Expect::spawn('Expect=GLOB(0x100eba4c0)', 'ssh -e none user@*
+***-idx-dev3.****.****.com') called at /Library/Perl/5.10.0/Net/SSH/E
+xpect.pm line 132
Net::SSH::Expect::run_ssh('Net::SSH::Expect=HASH(0x100e71bb0)'
+) called at /Library/Perl/5.10.0/Net/SSH/Expect.pm line 195
Net::SSH::Expect::login('Net::SSH::Expect=HASH(0x100e71bb0)')
+called at ./deploy_cluster.pl line 235
main::ssh_login('****-idx-dev3.****.****.com', 'user', 'passwo
+rd') called at ./deploy_cluster.pl line 187
main::copy_exist_to_old_all_servers('ARRAY(0x100e70ef0)', 'ARR
+AY(0x100e71448)') called at ./deploy_cluster.pl line 67
Starting EXPECT pattern matching...
at /System/Library/Perl/Extras/5.10.0/Expect.pm line 561.
Expect::expect('Expect=GLOB(0x100eba4c0)', 10, 'ARRAY(0x100eba
+7a8)', 'ARRAY(0x100eb5be8)', 'ARRAY(0x100e71cd0)', 'ARRAY(0x100eb5bd0
+)', 'ARRAY(0x100eba628)') called at /Library/Perl/5.10.0/Net/SSH/Expe
+ct.pm line 580
Net::SSH::Expect::_sec_expect('Net::SSH::Expect=HASH(0x100e71b
+b0)', 10, 'ARRAY(0x100eba7a8)', 'ARRAY(0x100eb5be8)', 'ARRAY(0x100e71
+cd0)', 'ARRAY(0x100eb5bd0)', 'ARRAY(0x100eba628)') called at /Library
+/Perl/5.10.0/Net/SSH/Expect.pm line 213
Net::SSH::Expect::login('Net::SSH::Expect=HASH(0x100e71bb0)')
+called at ./deploy_cluster.pl line 235
main::ssh_login('****-idx-dev3.****.****.com', 'user', 'passwo
+rd') called at ./deploy_cluster.pl line 187
main::copy_exist_to_old_all_servers('ARRAY(0x100e70ef0)', 'ARR
+AY(0x100e71448)') called at ./deploy_cluster.pl line 67
spawn id(5): list of patterns:
#1: -re `(?-xism:\\(yes/no\\)\\?\\s*$)'
#2: -re `(?-xism:[Pp]assword.*?:|[Pp]assphrase.*?:)'
#3: -re `(?-xism:ogin:\\s*$)'
#4: -re `(?-xism:REMOTE HOST IDEN)'
spawn id(5): Does `'
match:
pattern #1: -re `(?-xism:\\(yes/no\\)\\?\\s*$)'? No.
pattern #2: -re `(?-xism:[Pp]assword.*?:|[Pp]assphrase.*?:)'? No.
pattern #3: -re `(?-xism:ogin:\\s*$)'? No.
pattern #4: -re `(?-xism:REMOTE HOST IDEN)'? No.
spawn id(5): Does `Last login: Thu Oct 8 11:11:31 2015 from ****-idx-
+dev1.****.****.com\r\r\n'
match:
pattern #1: -re `(?-xism:\\(yes/no\\)\\?\\s*$)'? No.
pattern #2: -re `(?-xism:[Pp]assword.*?:|[Pp]assphrase.*?:)'? No.
pattern #3: -re `(?-xism:ogin:\\s*$)'? No.
pattern #4: -re `(?-xism:REMOTE HOST IDEN)'? No.
spawn id(5): Does `Last login: Thu Oct 8 11:11:31 2015 from ****-idx-
+dev1.****.****.com\r\r\n\033]0;****-idx-dev3.****.****.com:/Users/use
+r # \007'
match:
pattern #1: -re `(?-xism:\\(yes/no\\)\\?\\s*$)'? No.
pattern #2: -re `(?-xism:[Pp]assword.*?:|[Pp]assphrase.*?:)'? No.
pattern #3: -re `(?-xism:ogin:\\s*$)'? No.
pattern #4: -re `(?-xism:REMOTE HOST IDEN)'? No.
spawn id(5): Does `Last login: Thu Oct 8 11:11:31 2015 from ****-idx-
+dev1.****.****.com\r\r\n\033]0;****-idx-dev3.****.****.com:/Users/use
+r # \007\033[?1034h****-idx-dev3:~ user$ '
match:
pattern #1: -re `(?-xism:\\(yes/no\\)\\?\\s*$)'? No.
pattern #2: -re `(?-xism:[Pp]assword.*?:|[Pp]assphrase.*?:)'? No.
pattern #3: -re `(?-xism:ogin:\\s*$)'? No.
pattern #4: -re `(?-xism:REMOTE HOST IDEN)'? No.
Starting EXPECT pattern matching...
at /System/Library/Perl/Extras/5.10.0/Expect.pm line 561.
Expect::expect('Expect=GLOB(0x100eba4c0)', 10) called at /Libr
+ary/Perl/5.10.0/Net/SSH/Expect.pm line 580
Net::SSH::Expect::_sec_expect('Net::SSH::Expect=HASH(0x100e71b
+b0)', 10) called at /Library/Perl/5.10.0/Net/SSH/Expect.pm line 343
Net::SSH::Expect::peek('Net::SSH::Expect=HASH(0x100e71bb0)') c
+alled at /Library/Perl/5.10.0/Net/SSH/Expect.pm line 209
Net::SSH::Expect::__ANON__('ARRAY(0x100eb5678)') called at /Sy
+stem/Library/Perl/Extras/5.10.0/Expect.pm line 828
Expect::_multi_expect(10, 'ARRAY(0x100eb59a8)', 'ARRAY(0x100eb
+5e70)') called at /System/Library/Perl/Extras/5.10.0/Expect.pm line 5
+65
Expect::expect('Expect=GLOB(0x100eba4c0)', 10, 'ARRAY(0x100eba
+7a8)', 'ARRAY(0x100eb5be8)', 'ARRAY(0x100e71cd0)', 'ARRAY(0x100eb5bd0
+)', 'ARRAY(0x100eba628)') called at /Library/Perl/5.10.0/Net/SSH/Expe
+ct.pm line 580
Net::SSH::Expect::_sec_expect('Net::SSH::Expect=HASH(0x100e71b
+b0)', 10, 'ARRAY(0x100eba7a8)', 'ARRAY(0x100eb5be8)', 'ARRAY(0x100e71
+cd0)', 'ARRAY(0x100eb5bd0)', 'ARRAY(0x100eba628)') called at /Library
+/Perl/5.10.0/Net/SSH/Expect.pm line 213
Net::SSH::Expect::login('Net::SSH::Expect=HASH(0x100e71bb0)')
+called at ./deploy_cluster.pl line 235
main::ssh_login('****-idx-dev3.****.****.com', 'user', 'passwo
+rd') called at ./deploy_cluster.pl line 187
main::copy_exist_to_old_all_servers('ARRAY(0x100e70ef0)', 'ARR
+AY(0x100e71448)') called at ./deploy_cluster.pl line 67
spawn id(5): list of patterns:
spawn id(5): Does `Last login: Thu Oct 8 11:11:31 2015 from ****-idx-
+dev1.****.****.com\r\r\n\033]0;****-idx-dev3.****.****.com:/Users/use
+r # \007\033[?1034h****-idx-dev3:~ user$ '
match:
Uncaught exception from user code:
SSHAuthenticationError Login timed out. The input stream curre
+ntly has the contents bellow: Last login: Thu Oct 8 11:11:31 2015 fr
+om ****-idx-dev1.****.****.com
****-idx-dev3:~ user$ at /System/Library/Perl/Extras/5.10.0/Expect.pm
+ line 828.
at /Library/Perl/5.10.0/Net/SSH/Expect.pm line 209.
Net::SSH::Expect::__ANON__('ARRAY(0x100eb5678)') called at /Sy
+stem/Library/Perl/Extras/5.10.0/Expect.pm line 828
Expect::_multi_expect(10, 'ARRAY(0x100eb59a8)', 'ARRAY(0x100eb
+5e70)') called at /System/Library/Perl/Extras/5.10.0/Expect.pm line 5
+65
Expect::expect('Expect=GLOB(0x100eba4c0)', 10, 'ARRAY(0x100eba
+7a8)', 'ARRAY(0x100eb5be8)', 'ARRAY(0x100e71cd0)', 'ARRAY(0x100eb5bd0
+)', 'ARRAY(0x100eba628)') called at /Library/Perl/5.10.0/Net/SSH/Expe
+ct.pm line 580
Net::SSH::Expect::_sec_expect('Net::SSH::Expect=HASH(0x100e71b
+b0)', 10, 'ARRAY(0x100eba7a8)', 'ARRAY(0x100eb5be8)', 'ARRAY(0x100e71
+cd0)', 'ARRAY(0x100eb5bd0)', 'ARRAY(0x100eba628)') called at /Library
+/Perl/5.10.0/Net/SSH/Expect.pm line 213
Net::SSH::Expect::login('Net::SSH::Expect=HASH(0x100e71bb0)')
+called at ./deploy_cluster.pl line 235
main::ssh_login('****-idx-dev3.****.****.com', 'user', 'passwo
+rd') called at ./deploy_cluster.pl line 187
main::copy_exist_to_old_all_servers('ARRAY(0x100e70ef0)', 'ARR
+AY(0x100e71448)') called at ./deploy_cluster.pl line 67
Closing spawn id(5).
at /System/Library/Perl/Extras/5.10.0/Expect.pm line 1431.
Expect::hard_close('Expect=GLOB(0x100eba4c0)') called at /Syst
+em/Library/Perl/Extras/5.10.0/Expect.pm line 1621
Expect::DESTROY('Expect=GLOB(0x100eba4c0)') called at /Library
+/Perl/Updates/5.10.0/Carp.pm line 100
eval {...} called at /Library/Perl/Updates/5.10.0/Carp.pm line
+ 100
spawn id(5) closed.
Pid 3237 of spawn id(5) terminated, Status: 0xFF00
****-idx-dev1:manual user$
|