Thread Net::SSH2 Skript (9 answers)
Opened by cohama at 2011-10-20 11:12

cohama
 2011-10-20 11:12
#153353 #153353
User since
2011-08-16
102 Artikel
BenutzerIn

user image
Hallo zusammen,

ich habe für mein ssh-Skript, diese Bibliothek (libnet-ssh2-perl) in mein Ubuntu installiert und nun versuche ich eine ssh-Verbindung aufzubauen.
Leider funktioniert es nicht.

Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#################################
#!/usr/bin/perl -w
use strict; # declare the info before use
#################################
# packages
################################
use Net::SSH2; # ssh modul

##############################
# parameter definition
##############################
my $host = "192.168.178.15"; # Labor Linux PC
my $login = "foobar";
my $pw = "FoobarPW";

my $socket = Net::SSH2->new(); # ssh Socket
my $channel= $socket->channel(); # transfer tunnel

##############################
# main programm
##############################

$socket ->connect($host) or die("connect(): $!\n"); # establish the connection

if ($socket->auth_password($login,$pw))
{
$channel ->shell(); # shell command
print $channel "uname -a\n";
select(undef,undef,undef,0.2);
$channel->close; # cut the tunnel
} else {
warn "auth failed.\n";
}


Diese Fehlermeldung erscheint stets.
connect(): Die Ressource ist zur Zeit nicht verfügbar
Wenn ich auf er Konsole eine ssh-Verbindung zum ssh-Server aufbaue, funktioniert es fehlerfrei.
An welcher Stelle muss ich was verändern?

View full thread Net::SSH2 Skript