#!/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; #### $ ./ssh.pl Password: libssh2_channel_open_ex(ss->session, pv_channel_type, len_channel_type, window_size, packet_size, ((void *)0) , 0 ) -> 0x1b10be0 Net::SSH2::poll: timeout = 10000, array[0] Net::SSH2::poll: timeout = 250, array[1] - [0] = channel - [0] events 1 - libssh2_poll returned 0 - [0] revents 0 Net::SSH2::Channel::DESTROY Net::SSH2::DESTROY object 0x1a055a0