Thread

Posted on Fri Aug 4 00:10:45 2006 by opensrcguru
net-ssh-perl hangs an excessive cpu usage
folks, i have a simple script that is to ssh to a remote host and return the output of uname -a. sounds simple enought...right? the script is taking forever to complete and chews up tons of cpu while trying to accomplish my task. do you guys have any idea what the issue may be?
#!/usr/bin/perl use strict; use Net::SSH::Perl; use Net::SSH::Perl::Auth; my %params = ( protocol =&gt 2, interactive =&gt 0, debug =&gt 1, ); my $ssh = Net::SSH::Perl-&gtnew("10.121.121.5",%params); $ssh-&gtlogin("dbc","dbc123"); my($stdout, $stderr, $exit) = $ssh->cmd("uname -a"); print STDOUT "\$stdout = $stdout\n"; print STDOUT "\$stderr = $stderr\n"; print STDOUT "\$exit = $exit\n";
Direct Responses: 2751 | Write a response
Posted on Fri Aug 4 17:38:15 2006 by opensrcguru in response to 2749
Re: net-ssh-perl hangs an excessive cpu usage
i'm also seeing this issue with the sample scripts in the eg/ directory from the source distrobution. are there compatibility issues with some of the other required modules? the scripts seem to hang with excessive cpu usage during the "Verifying server signature" phase according to the debug output.
Direct Responses: 4029 | Write a response
Posted on Sun Jan 14 01:25:40 2007 by samnelson in response to 2751
Re: net-ssh-perl hangs an excessive cpu usage

I was also seeing this same problem with the script I have listed below. After trying the advice in post 2689 which says to downgrade the Crypt-DH module, I was able to stop my script from hanging on these debug messages:

localhost: Sent key-exchange init (KEXINIT), wait response. localhost: Algorithms, c->s: 3des-cbc hmac-sha1 none localhost: Algorithms, s->c: 3des-cbc hmac-sha1 none

However, the script now hung for about 1 to 2 minutes on another debug message:

localhost: Verifying server signature.

As a last ditch I tried downgrading the Crypt-DSA module and that fixed the problem!

In order that I did it, here are the modules I downgraded:

Crypt-DH 0.06 to Crypt-DH 0.03
Crypt-Random 1.25 to Crypt-Random 1.23 (I'm not sure if this one was really neccesary)
Crypt-DSA 0.14 to Crypt-DSA 0.12

I don't know if there are any issues with Crypt-RSA as I was not using that module for authentication. You might try downgrading that one if you still experience problems.

Hope that helps,

Sam

#!/usr/bin/perl use Net::SSH::Perl; my $host = "localhost"; my $user = "username"; my $pass = "password"; my $cmd = "ls"; my $ssh = Net::SSH::Perl->new($host, debug => 1, protocol => '2,1', options => ['PasswordAuthentication yes', 'HostbasedAuthentication no']); print "Connecting to host: $host"; $ssh->login($user, $pass); my($stdout, $stderr, $exit) = $ssh->cmd($cmd); print $stdout;
Direct Responses: 4032 | Write a response
Posted on Mon Jan 15 14:03:32 2007 by wardmw in response to 4029
Re: net-ssh-perl hangs an excessive cpu usage

Thanks for the advice Sam. Following your recommendations I downgraded:

Crypt-DH 0.06 to Crypt-DH 0.03
Crypt-DSA 0.14 to Crypt-DSA 0.12

and it's now working much better. I don't fully understand the link between the Crypt and PERI modules but can leave that bit of it for now.

I now need to rewrite the "fatal_disconnect" code so that the system doesn't terminate the whole program if it can't connect, but that's a whole different set of problems!

|\/|artin
Write a response