################################# #!/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"; }