Net::SSH::Perl::Config(3)

NAME
Net::SSH::Perl::Config - Load and manage SSH configuration

SYNOPSIS
    use Net::SSH::Perl::Config;
    my $cfg = Net::SSH::Perl::Config->new($host, foo => 'bar');
    $cfg->read_config($config_file);
    my $v = $cfg->get('foo');

DESCRIPTION
Net::SSH::Perl::Config manages configuration data for Net::SSH::Perl. It merges options handed to it at object construction with options read from configuration files. Just as in the actual ssh program, the first obtained value of a configuration parameter is the value that's used; in other words, values given in the original parameter list will always override values read from configuration files.

The configuration files should be in the same format used for the ssh command line program; see the ssh manpage for information on this format. Net::SSH::Perl::Config understands a subset of the configuration directives that can live in these files; this subset matches up with the functionality that Net::SSH::Perl can support. Unknown keywords will simply be skipped.

USAGE

  Net::SSH::Perl::Config->new($host, %args)
Constructs a new configuration container object and returns that object. $host is the host to which you're applying this configuration; you can leave it out (pass in an undefined or empty argument) if it's not applicable to you.

$host is needed for parsing the host-specific sections of the configuration files; the Host keyword restricts a set of directives as applying to a particular host (or set of hosts). When it encounters such a section, Net::SSH::Perl::Config will skip all of the directives in the section unless the host matches $host.

%args can contain the same arguments that you can pass to the new method of Net::SSH::Perl--those arguments are eventually passed through to this method when setting up the SSH object. The elements in %args override values in the configuration files.

  $cfg->read_config($file)
Reads in the configuration file $file and adds any appropriate configuration data to the settings maintained by the $cfg object. If $file is unreadable, simply returns quietly.

As stated above, values read from the configuration files are overridden by those passed in to the constructor. Furthermore, if you're reading from several config files in sequence, values read from the first files will override those read from the second, third, fourth, etc. files.

  $cfg->merge_directive($line)
Merges the directive option $line into the configuration settings in $cfg. $line should be an option in the format used in the config file, eg. "BatchMode yes". This is useful for merging in directives that are not necessarily in the config file, similar to how the -o option works in the ssh command line program.

  $cfg->get($key)
Returns the value of the configuration parameter $key, and undefined if that parameter has not been set.

  $cfg->set($key, $value)
Sets the value of the parameter $key to $value, and returns the new value.

AUTHOR & COPYRIGHTS
Please see the Net::SSH::Perl manpage for author, copyright, and license information.