.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Net::SSH::AuthorizedKey 3pm" .TH Net::SSH::AuthorizedKey 3pm "2018-06-01" "perl v5.26.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Net::SSH::AuthorizedKey \- Virtual Base Class for SSH Public Keys .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Net::SSH::AuthorizedKey; \& \& # Either parse a string (without leading whitespace or comments): \& my $key = Net::SSH::AuthorizedKey\->parse( $line ); \& \& if(defined $key) { \& # ssh\-1 or ssh\-2 \& print "Key parsed, type is ", $key\->type(), "\en"; \& } else { \& die "Cannot parse key \*(Aq$line\*(Aq"; \& } \& \& # ... or create an object yourself: \& my $pubkey = Net::SSH::AuthorizedKey\->new( \& options => { from => \*(Aqfoo@bar.com\*(Aq, \& "no\-agent\-forwarding" => 1 }, \& key => "123....890", \& keylen => 1024, \& exponent => 35, \& type => "ssh\-1", \& ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Net::SSH::AuthorizedKey is a virtual base class for ssh public keys. Real implementations of it are Net::SSH::AuthorizedKey::SSH1 and Net::SSH::AuthorizedKey::SSH2. .PP The only way to using it directly is by calling its \fIparse()\fR method, and passing it an authorized_keys string (aka a line from an authorized_keys file). If it recognizes either a ssh\-1 or a ssh\-2 type key, it will return a Net::SSH::AuthorizedKey::SSH1 or a Net::SSH::AuthorizedKey::SSH2 object, both of which support the accessor methods defined in the \s-1FIELDS\s0 section below. .PP The \fIas_string()\fR method will cobble the (perhaps modified) fields together and return them as a string suitable as a line for an authorized_keys file. .SS "\s-1METHODS\s0" .IX Subsection "METHODS" .ie n .IP """parse( $line )""" 4 .el .IP "\f(CWparse( $line )\fR" 4 .IX Item "parse( $line )" Reads in a single text line containing a ssh\-1 or ssh\-2 key. Returns a Net::SSH::AuthorizedKey::SSH1 or a Net::SSH::AuthorizedKey::SSH2 object, or \f(CW\*(C`undef\*(C'\fR in case of an error. .ie n .IP """fingerprint()""" 4 .el .IP "\f(CWfingerprint()\fR" 4 .IX Item "fingerprint()" Returns a \s-1MD5\s0 hex hash of the parsed key. The hash is unique for functionally identical keys. Fields not contributing to the key's functional uniqueness are ignored. .ie n .IP """error()""" 4 .el .IP "\f(CWerror()\fR" 4 .IX Item "error()" Returns the last parsing error encountered as a text string. .ie n .IP """as_string( )""" 4 .el .IP "\f(CWas_string( )\fR" 4 .IX Item "as_string( )" Return the object as a string suitable as a autorized_keys line. .SS "\s-1FIELDS\s0" .IX Subsection "FIELDS" All of the following fields are available via accessors: .ie n .IP """type""" 4 .el .IP "\f(CWtype\fR" 4 .IX Item "type" Type of ssh key, usually \f(CW"ssh\-1"\fR or \f(CW"ssh\-2"\fR. .ie n .IP """key""" 4 .el .IP "\f(CWkey\fR" 4 .IX Item "key" Public key, either a long number (ssh\-1) or a line of alphanumeric characters (ssh\-2). .ie n .IP """keylen""" 4 .el .IP "\f(CWkeylen\fR" 4 .IX Item "keylen" Length of the key in bit (e.g. 1024). .ie n .IP """exponent""" 4 .el .IP "\f(CWexponent\fR" 4 .IX Item "exponent" Two-digit number in front of the key in ssh\-1 authorized_keys lines. .ie n .IP """options""" 4 .el .IP "\f(CWoptions\fR" 4 .IX Item "options" Returns a reference to a hash with options key/value pairs, listed in front of the key. .SS "\s-1IMPLEMENTATION REFERENCE\s0" .IX Subsection "IMPLEMENTATION REFERENCE" The key parsers implemented in this distribution are implemented similarily as the authorized_keys file parser in the openssh source distribution. .PP Openssh contains the authorized_keys parser in its auth2_pubkey.c file. The \fIuser_key_allowed2()\fR function opens the file and reads it line by line, ignoring leading whitespace, empty and comment lines. .PP After that, if a line doesn't contain a plain key, the parser skips ahead until the first whitespace (zooming through quoted areas \*(L"...\*(R" and interpreting '\e"' as an escaped quote), then skips this whitespace and tries to read a key one more time. .PP Regarding options, the Perl parser isn't as elaborate with semantic peculiarities as openssh's \fIauth_parse_options()\fR, but this might be added in the future. .SH "NOTES FOR SUBCLASS DEVELOPERS" .IX Header "NOTES FOR SUBCLASS DEVELOPERS" If you're just using Net::SSH::AuthorizedKey to parse keys, the following section doesn't concern you. It's only relevant if you add new subclasses to this package, on top of what's already provided. .PP Net::SSH::AuthorizedKey is a (semi\-)virtual base class that implements options handling for its \s-1SSH1\s0 and \s-1SSH2\s0 subclasses. .PP \&\s-1SSH\s0 key lines can contain options that carry values (like command=\*(L"ls\*(R") and binary options that are either set or unset (like \*(L"no_agent_forwarding\*(R"). To distinguish the two, and to provide a set of allowed option names, the subclass has to implement the method \fIoption_type()\fR, which takes an option name, and returns .IP "\(bu" 4 undef if the option is not supported .IP "\(bu" 4 \&\*(L"s\*(R" if the option is a \*(L"string\*(R" option that carries a value .IP "\(bu" 4 1 if the option is a binary option .PP The subclasses Net::SSH::AuthorizedKey::SSH1 and Net::SSH::AuthorizedKey::SSH2 are doing this already. .SH "LEGALESE" .IX Header "LEGALESE" Copyright 2005\-2009 by Mike Schilli, all rights reserved. This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself. .SH "AUTHOR" .IX Header "AUTHOR" 2005, Mike Schilli