#!/usr/bin/perl use strict; use warnings; use Net::SSH2; use Term::ReadKey; my $host = '192.168.123.5'; my $user = 'root'; my $pass = getpass(); my $ssh = Net::SSH2->new(); $ssh->connect($host) or die $!; $ssh->auth_password($user,$pass) or die $!; my $chan = $ssh->channel(); $chan->shell(); print $chan "/sbin/service syslog restart"; print "$_" while <$chan>; $chan->close; $ssh->disconnect;