NAME

Config::OpenSSH::Authkey::Entry::Options - authorized_keys entry options handler

SYNOPSIS

Parse an options string:

  my $op =
    Config::OpenSSH::Authkey::Entry::Options->new('no-pty,no-user-rc');
  
  $op->set_option('from', '127.0.0.1');
  $op->unset_option('no-pty');
  print $op->as_string;

DESCRIPTION

This module parses option strings (no-pty,from="",...) from OpenSSH authorized_keys files. It is used by Config::OpenSSH::Authkey::Entry. Consult the AUTHORIZED_KEYS FILE FORMAT section of sshd(8) for more information about these options.

CLASS METHODS

new optional option string to parse

Constructor. Optionally accepts an option string to parse.

split_options option string

Accepts a string of comma separated options, and parses these into a list of hash references. In scalar context, returns a reference to the list. In list context, returns a list.

INSTANCE METHODS

parse option string

Utility method in the event an option string was not passed to new.

get_option option name

Returns the value (or values) for a named option. OpenSSH does allow duplicate entries for options, though in most cases this method will only return a single value. Options are boolean or string value; boolean options return the name of the method, while string options return the string value. Assuming the options have been set as shown above:

  # returns 'no-agent-forwarding'
  $entry->get_option('no-agent-forwarding');
  
  # returns '127.0.0.1'
  $entry->get_option('from');

In scalar context, only the first option is returned (or the empty string). In list context, a list of one (or rarely more) values will be returned (or the empty list).

get_options

Returns a list of all option names that exist in the instance.

set_option option name, optional value

Enables an option, or with an additional argument, sets the string value for that option.

  # boolean
  $entry->set_option('no-agent-forwarding');
  
  # string value
  $entry->set_option(from => '127.0.0.1');

If multiple options with the same name are present in the options list, only the first option found will be updated, and all subsequent entries removed from the options list.

unset_option option name

Deletes all occurrences of the named option.

unset_options

Removes all options.

as_string

Returns the options as a comma separated value list. Any option values that contain a doublequote (") that is not escaped with a backslash (\) will be escaped with a backslash.

BUGS

No known bugs. Newer versions of this module may be available from CPAN.

If the bug is in the latest version, send a report to the author. Patches that fix problems or add new features are welcome.

SEE ALSO

sshd(8), ssh-keygen(1), Config::OpenSSH::Authkey::Entry

AUTHOR

thrig - Jeremy Mates (cpan:JMATES) <jmates at cpan.org>

COPYRIGHT

Copyright 2010,2015,2019 by Jeremy Mates

This program is distributed under the (Revised) BSD License: http://www.opensource.org/licenses/BSD-3-Clause