################################# #!/usr/bin/perl -w use strict; # declare the info before use ################################# # packages ################################ use Net::SSH2; # ssh modul ############################## # parameter definition ############################## my $host = '192.168.93.135'; # Labor Linux PC my $luser = "foobar"; my $pw = "FoobarPW"; my $socket = Net::SSH2->new(); # ssh Socket my $session; # Authentication my $channel; # my $resp; # Server Answer ############################## # main programm ############################## system("clear"); # Refresh the commands $socket ->connect($host) or die("connect(): $!\n"); # establish the connection print "Connection to Server established \n"; $socket->auth_password($luser,$pw); if ($socket->auth_ok()) { $channel =$socket->channel(); # shell command print "Channel ready\n"; $channel->exec('uname -a'); # run command at ssh-Server print "Command tranfert \n"; while ($channel->read($resp,1024)) { # get the Response print $resp; } $channel->close(); $socket->disconnect(); } else { print STDERR "authentication failed\n"; }