Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Net::SSH::Perl : multiple connections fails

Reply
Thread Tools

Net::SSH::Perl : multiple connections fails

 
 
Helge Cramer
Guest
Posts: n/a
 
      10-10-2003
I installed Net::SSH:erl and everything works fine
But trying to connect to multiple servers brings out error-message:

Net::SSH: Can't bind socket to port 1023

$ssh1 = Net::SSH:erl->new('host1', protocol => '2,1');
$ssh2 = Net::SSH:erl->new('host2', protocol => '2,1');

Alternatively, I tried to set up the second connection after remote
commands on first connection exited, but it just brought up the same
error.
I think, I am missing a hint for "unbinding" the socket/close the
connection before connect to second server or a hint for an
opportunity to speak with both servers at the same time.

I am running RedHat9 on an intel-box and on remote servers sshd is
listening to port 23 only.

Thanks for any hint/solution,

Helge Cramer
 
Reply With Quote
 
 
 
 
lostriver
Guest
Posts: n/a
 
      10-10-2003
On 10 Oct 2003 09:04:23 -0700, Helge Cramer wrote:
> I installed Net::SSH:erl and everything works fine
> But trying to connect to multiple servers brings out error-message:
>
> Net::SSH: Can't bind socket to port 1023


You are not runing it as root, right? Only root can use local ports 0-1023....
Are you sure you do not have 'privileged => 1' set?


--
..signature: No such file or directory
 
Reply With Quote
 
 
 
 
Helge Cramer
Guest
Posts: n/a
 
      10-13-2003
Yes, I do run the script as root, so Net::SSH:erl should set
privileged=1 on its own (as described in the documentation).
Any further suggestions (perhaps how to make connection 2 after
connection 1)?

Helge Cramer
 
Reply With Quote
 
ko
Guest
Posts: n/a
 
      10-14-2003
Helge Cramer wrote:
> Yes, I do run the script as root, so Net::SSH:erl should set
> privileged=1 on its own (as described in the documentation).
> Any further suggestions (perhaps how to make connection 2 after
> connection 1)?
>
> Helge Cramer


Have you tried the sock() method? From the Net::SSH:erl docs:

$ssh->sock

Returns the socket connection to sshd. If your client is not connected,
dies.

Then use the return value to explicitly shutdown/close the connection,
and make try making a second connection.

Off-topic, but have you thought about using a combination public key
authentication and cron setup? Not sure exactly what you want to do, but
this method will also allow you to control what gets executed (since
you're running root). Just a suggestion, though...

HTH - keith

 
Reply With Quote
 
lostriver
Guest
Posts: n/a
 
      10-14-2003
On 13 Oct 2003 05:35:43 -0700, Helge Cramer wrote:
> Yes, I do run the script as root, so Net::SSH:erl should set
> privileged=1 on its own (as described in the documentation).
> Any further suggestions (perhaps how to make connection 2 after
> connection 1)?
>


Post your code. It is hard to guess what you are doing...

This work just fine for me:


use Net::SSH:erl;

foreach (1..3) {
$i = Net::SSH:erl->new(localhost);
$i->login('username', 'password');
push @connections, $i;

next unless $_ == 2;
my ($stdout, $stderr, $exit) = $i->cmd('ls');
print "First loop: $_: $stdout\n";
}


foreach $i (@connections) {
my ($stdout, $stderr, $exit) = $i->cmd('ls');
print "Second loop: $stdout\n";
}




--
..signature: No such file or directory
 
Reply With Quote
 
Helge Cramer
Guest
Posts: n/a
 
      10-15-2003
I tried the code You posted, but it is not working for me either. I am
still getting error message:

Net::SSH: Can't bind socket to port 1023: Die Adresse wird bereits
verwendet

(Address already in use)


Here my modified code according to Your last posting:

my %servers = (
host1 => {
host => "host1.somewhere.net",
user => "user1",
pass => "pass1",
logdir => "www/logs",
cmd_zip => "gzip -9 www/logs/*_access",
cmd_ls => "ls www/logs/*_access.gz",
cmd_delete => "rm -f www/logs/*.gz",
hold_flag => 0,
},
host2 => {
host => "host2.somewhere.net",
user => "user2",
pass => "pass2",
logdir => "www/logs",
cmd_zip => "gzip -9 www/logs/access_log_*",
cmd_ls => "ls www/logs/access_log_*.gz",
cmd_delete => "rm -f www/logs/*.gz",
hold_flag => 0,
},
);

my @connections;
my $i;
my $server;
foreach $server (keys %servers) {
$i = Net::SSH:erl->new($servers{$server}{host});
$i->login($servers{$server}{username});
push @connections, $i;

next unless $_ eq "host2";
my ($stdout, $stderr, $exit) = $i->cmd('ls');
print "First loop: $_: $stdout\n";
}


foreach $i (@connections) {
my ($stdout, $stderr, $exit) = $i->cmd('ls');
print "Second loop: $stdout\n";
}


According to the suggestion to cron: Yes, I want a cron-job to do the
thing, but there a several servers I want to connect to and so I want
just running the cron-job on one system in my office. Authentification
is through public-key (rsa) as servers do support it.
Password-Authentification is only for remote servers where I do not
have root-access and no opportunity to authentificate via key-pairs.

Helge Cramer
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Lingering Idle Oracle Connections? Persistent connections? jobs ASP .Net 2 11-16-2007 03:37 AM
Constant.t fails 240 of 272 tests and recurs.t fails 1 of 25 tests on HPUX using perl 5.8.7 dayo Perl Misc 11 12-16-2005 09:09 PM
Routing through multiple wireless Internet Connections =?Utf-8?B?SkdlcmVuZHQ=?= Wireless Networking 0 10-19-2005 07:26 PM
slideshow fails, Firefox debugger also fails lkrubner@geocities.com Javascript 2 12-23-2004 06:22 PM
Forms Authentication Fails Between ASP.NET 1.0 and 1.1 Applications (Cookie Decryption Fails) John Saunders ASP .Net 1 11-18-2003 03:25 PM



Advertisments