ePages 6.10 - DE_EPAGES/FlexVirtuozzoProvider/API/SSH.pm

Package DE_EPAGES::FlexVirtuozzoProvider::API::SSH

This Module collects useful functions to connect to a remote server with SSH and execute commands with ssh

@EXPORT_OK
ConnectServer
Execute

Functions

ConnectServer
Execute

ConnectServer

Creates a connection handle to an SSH Server. The client test to login with the most secure auth methods first. (pubkey,password,etc.) If no Input is given, the config file ss.conf is used.

Syntax
ConnectServer( $hParams );
Input
$hParams (reference to hash)
params for connection | with following keys:
  • HNIPOrName - HardwareNode name or ip adress - string
  • SSHIdentity (optional) - ssh identity file - string
  • SSHThisHost (optional) - the name of this host - string
  • SSHThisUser (optional) - the current user of this host - string
  • SSHLogin - ssh server login - string
  • SSHPassword - ssh server password - string
Output
$ssh - ssh handle to the server - Net::SSH2 object

Execute

execute te a single statement and return the stdout, stderr,exitcode of the statement

Syntax
Execute( $ssh2,$Statement,$sResult);
Example
my ($stdout,$stderr,$exit) = Execute( $ssh ,'ls -la');
Input
$ssh (Net::SSH::Perl object)
ssh handle to the server
$Statement (string)
statement to execute on the server
Output
$stdout (string)
stdout of the statement
$stderr (string)
stderr of the statement
$exit (integer)
exit code of the statement