#!/usr/bin/perl -- use Control::CLI; use Net::SSH2; ############# CONFIGURATION VARIABLES ############### $aps_path = '/scripts/'; #Path where perl script is stored $aps_path_log_path = '/scripts/LOGS/'; #Path where logs will be stored $ssh_public_key = $aps_path.'ssh_private.key.pub'; #Path where rsa public key is $ssh_private_key = $aps_path.'ssh_private.key'; #Path where rsa private key is $ssh_key_passphrase = 'test_key_rsa'; $session_timeout = 20; # value in seconds $exec_timeout = 10; # value in seconds $remote_ip = '10.0.0.1'; $user_login = 'test_user'; #!!!# WARNING #!!!# ---->> clear after use !!! $user_password = 'test_password'; #!!!# WARNING #!!!# ---->> clear after use !!! ############# APPLICATION ################## my $ssh_session = new Control::CLI(Use => 'SSH', Timeout => $session_timeout, Input_log => $aps_path_log_path.'IN_LOGS.log', Output_log => $aps_path_log_path.'OUT_LOGS.log'); $ssh_session->connect( Host => $remote_ip, Username => $user_login, Password => $user_password, PublicKey => $ssh_public_key, PrivateKey => $ssh_private_key, Passphrase => $ssh_key_passphrase, errmode => 'return'); if($ssh_session->errmsg()){ print "Something goes wrong !\n"; } else{ $ssh_session->cmd(Command => 'terminal length 0', Timeout => $exec_timeout, Errmode => Return); $ssh_session->cmd(Command => 'show clock', Timeout => $exec_timeout, Errmode => Return); $ssh_session->cmd(Command => '', Timeout => $exec_timeout, Errmode => Return); if($ssh_session->errmsg()){ print "\nSomething goes wrong after sending commands!\n Check your logs\n"; } else{ print "\nOK! Check your logs\n"; undef $ssh_session; } } print "\nPress any key to continue\n"; ; ############################################################## ################### DESCRIPTION.PL ########################### ##############################################################