NAME
Data::SSHPubkey - utility function to parse SSH public keys with
SYNOPSIS
use Data::SSHPubkey;
my $keylist = Data::SSHPubkey::pubkeys( $file_or_scalarref );
for my $ref ( @$keylist ) {
my ($type, $pubkey) = @$ref;
...
}
DESCRIPTION
Data::SSHPubkey
parses SSH public keys, or at least some of those supported by ssh-keygen(1)
. It may be prudent to check any uploaded data with ssh-keygen
though this module should help extract that from web form upload data or the like to get to that step.
Currently supported public key types:
ecdsa ed25519 rsa
PEM PKCS8 RFC4716
Neither SSH1 keys nor SSH2 DSA keys are supported.
SUBROUTINE
- pubkeys filename-or-scalarref
-
A filename (scalar) will be opened and the public keys therein parsed; a scalar reference will be treated as an in-memory file and will likewise be opened and parsed.
This routine will croak on error as, in theory, all the errors should be due to the data passed in by the caller, or possibly the system has run out of memory, or something.
The return format is a reference to a list of
[ $type, $pubkey ]
lists.
BUGS
Please report any bugs or feature requests to bug-data-sshpubkey at rt.cpan.org
, or through the web interface at https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-SSHPubkey. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
Patches might best be applied towards:
https://github.com/thrig/Data-SSHPubkey
Known Issues
Probably not enough guards or checks against hostile input (too much data, etc).
Support for the
PEM PKCS8 RFC4716
key types is pretty weak and needs improvement.
SEE ALSO
Config::OpenSSH::Authkey - older module more aimed at management of ~/.ssh/authorized_keys
data and not specifically public keys. It does have support for SSH2 DSA or SSH1 keys, though.
AUTHOR
thrig - Jeremy Mates (cpan:JMATES) <jmates at cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2019 by Jeremy Mates
This program is distributed under the (Revised) BSD License: http://www.opensource.org/licenses/BSD-3-Clause