NAME

XAS::Lib::SSH::Client - A SSH based client

SYNOPSIS

use XAS::Lib::SSH::Client;

my $client = XAS::Lib::SSH::Client->new(
   -host    => 'auburn-xen-01',
   -username => 'root',
   -password => 'secret',
);

$client->connect();

$client->put($data);
$data = $client->get();

$client->disconnect();

DESCRIPTION

The module provides basic network connectivity along with input/output methods using the SSH protocol. It can authenticate using username/password or username/public key/private key/password.

METHODS

new

This initializes the object. It takes the following parameters:

-username

An optional username to use when connecting to the server.

-password

An optional password to use for authentication.

-pub_key

An optional public ssh key file to use.

-priv_key

An optional private ssh key to use.

-host

The server to connect too. Defaults to 'localhost'.

-port

The port to use on the server. It defaults to 22.

-timeout

The number of seconds to timeout writes. It must be compatible with IO::Select. Defaults to 0.2.

-eol

The EOL to use, defaults to "\015\012".

connect

This method makes a connection to the server.

setup

This method sets up the channel to be used. It needs to be overridden to be useful.

get($length)

This block reads data from the channel. A buffer is returned when it reaches $length or timeout, whichever is first.

$length

An optional length for the buffer. Defaults to 512 bytes.

gets

This reads a buffer delimited by the eol from the channel.

errno

A class method to return the SSH error number.

errstr

A class method to return the SSH error string.

put($buffer)

This method will write a buffer to the channel. Returns the number of bytes written.

$buffer

The buffer to be written.

puts($buffer)

This writes a buffer that is terminated with eol to the channel. Returns the number of bytes written.

$buffer

The buffer to send over the socket.

disconnect

This method closes the connection.

MUTATORS

attempts

This is used when reading data from the channel. It triggers how many times to attempt reading from the channel when a LIBSSH2_ERROR_EAGAIN error occurs. The default is 5 times.

SEE ALSO

XAS

AUTHOR

Kevin L. Esteb, <kevin@kesteb.us>

COPYRIGHT AND LICENSE

Copyright (C) 2014 Kevin L. Esteb

This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license at http://www.perlfoundation.org/artistic_license_2_0.