Hi Everyone,
I've been trying to figure out why my script hangs for 3-4 minutes prior to executing the command remotely. I know it's related to key authentication since I do not have these issues when using a username\password. I've searched for 2 days and still can't find my solution.
I just started programming so please don't flame me if I say something stupid.
Here's the code that works without a hitch:
#!/usr/bin/perl
use strict;
use Net::SSH:erl;
my $ssh = Net::SSH:erl->new('172.16.10.220',debug => 1, protocol => '2,1');
$ssh->login('monitor','12345');
my ($stdout, $stderr, $exit) = $ssh->cmd('pwd');
print $stdout . "\n";
print $stderr . "\n";
print $exit . "\n";
I then created SSH keys and confirmed that I can connect without passwords from the CLI. When taking the next step, it works however it stay stuck for 3-4 minutes before executing. Here's the script:
#!/usr/bin/perl
use strict;
use warnings;
use Net::SSH:erl;
my $host = "172.16.11.220";
my $user = "monitor";
my $cmd = "mkdir working";
my $ssh = Net::SSH:erl->new($host, debug => 1, identity_files => ["/root/.ssh/id_rsa"], protocol=>'2,1');
$ssh->login($user);
my($stdout, $stderr, $exit) = $ssh->cmd($cmd);
print "$stdout";
print "$stderr";
print "$exit";
Here's the logs:
# perl Test2.pl
Reading configuration data /root/.ssh/config
Reading configuration data /etc/ssh_config
Allocated local port 1023.
Connecting to 172.16.11.63, port 22.
Remote protocol version 2.0, remote software version OpenSSH_4.3
Net::SSH:erl Version 1.33, protocol version 2.0.
No compat match: OpenSSH_4.3.
Connection established.
Sent key-exchange init (KEXINIT), wait response.
Algorithms, c->s: 3des-cbc hmac-sha1 none
Algorithms, s->c: 3des-cbc hmac-sha1 none
Entering Diffie-Hellman Group 1 key exchange.
Sent DH public key, waiting for reply.
Received host key, type 'ssh-dss'.
Host '172.16.11.220' is known and matches the host key.
Computing shared secret key.
Verifying server signature.
Waiting for NEWKEYS message.
Enabling incoming encryption/MAC/compression.
Send NEWKEYS, enable outgoing encryption/MAC/compression.
Sending request for user-authentication service.
Service accepted: ssh-userauth.
Trying empty user-authentication request.
Authentication methods that can continue: publickey,password,keyboard-interactive.
Next method to try is publickey.
Trying pubkey authentication with key file '/root/.ssh/id_rsa'
**it stays stuck here for 3-4 minutes before executing...
Can anyone point me in the right direction?
Thanks
I've been trying to figure out why my script hangs for 3-4 minutes prior to executing the command remotely. I know it's related to key authentication since I do not have these issues when using a username\password. I've searched for 2 days and still can't find my solution.
I just started programming so please don't flame me if I say something stupid.
Here's the code that works without a hitch:
#!/usr/bin/perl
use strict;
use Net::SSH:erl;
my $ssh = Net::SSH:erl->new('172.16.10.220',debug => 1, protocol => '2,1');
$ssh->login('monitor','12345');
my ($stdout, $stderr, $exit) = $ssh->cmd('pwd');
print $stdout . "\n";
print $stderr . "\n";
print $exit . "\n";
I then created SSH keys and confirmed that I can connect without passwords from the CLI. When taking the next step, it works however it stay stuck for 3-4 minutes before executing. Here's the script:
#!/usr/bin/perl
use strict;
use warnings;
use Net::SSH:erl;
my $host = "172.16.11.220";
my $user = "monitor";
my $cmd = "mkdir working";
my $ssh = Net::SSH:erl->new($host, debug => 1, identity_files => ["/root/.ssh/id_rsa"], protocol=>'2,1');
$ssh->login($user);
my($stdout, $stderr, $exit) = $ssh->cmd($cmd);
print "$stdout";
print "$stderr";
print "$exit";
Here's the logs:
# perl Test2.pl
Reading configuration data /root/.ssh/config
Reading configuration data /etc/ssh_config
Allocated local port 1023.
Connecting to 172.16.11.63, port 22.
Remote protocol version 2.0, remote software version OpenSSH_4.3
Net::SSH:erl Version 1.33, protocol version 2.0.
No compat match: OpenSSH_4.3.
Connection established.
Sent key-exchange init (KEXINIT), wait response.
Algorithms, c->s: 3des-cbc hmac-sha1 none
Algorithms, s->c: 3des-cbc hmac-sha1 none
Entering Diffie-Hellman Group 1 key exchange.
Sent DH public key, waiting for reply.
Received host key, type 'ssh-dss'.
Host '172.16.11.220' is known and matches the host key.
Computing shared secret key.
Verifying server signature.
Waiting for NEWKEYS message.
Enabling incoming encryption/MAC/compression.
Send NEWKEYS, enable outgoing encryption/MAC/compression.
Sending request for user-authentication service.
Service accepted: ssh-userauth.
Trying empty user-authentication request.
Authentication methods that can continue: publickey,password,keyboard-interactive.
Next method to try is publickey.
Trying pubkey authentication with key file '/root/.ssh/id_rsa'
**it stays stuck here for 3-4 minutes before executing...
Can anyone point me in the right direction?
Thanks