1Net::SSH::Perl::Key(3)User Contributed Perl DocumentationNet::SSH::Perl::Key(3)
2
3
4

NAME

6       Net::SSH::Perl::Key - Public or private key abstraction
7

SYNOPSIS

9           use Net::SSH::Perl::Key;
10           my $key = Net::SSH::Perl::Key->new;
11

DESCRIPTION

13       Net::SSH::Perl::Key implements an abstract base class interface to key
14       objects (either DSA or RSA keys, currently). The underlying implementa‐
15       tion for RSA is an internal, hash-reference implementation; the DSA
16       implementation uses Crypt::DSA.
17

USAGE

19       Net::SSH::Perl::Key->new($key_type [, $blob [, $compat_flag_ref ]])
20
21       Creates a new object of type Net::SSH::Perl::Key::$key_type, after
22       loading the class implementing $key_type. $key_type should be either
23       "DSA" or "RSA1", currently; these are the only supported key implemen‐
24       tations at the moment.
25
26       $blob, if present, should be a string representation of the key, from
27       which the key object can be initialized. In fact, it should be the rep‐
28       resentation that is returned from the as_blob method, below.
29
30       $compat_flag_ref should be a reference to the SSH compatibility flag,
31       which is generally stored inside of the Net::SSH::Perl object. This
32       flag is used by certain key implementations ("DSA") to work around dif‐
33       ferences between SSH2 protocol implementations.
34
35       Returns the new key object, which is blessed into the subclass.
36
37       Net::SSH::Perl::Key->read_private($key_type, $file [, $pass])
38
39       Reads a private key of type $key_type out of the key file $file. If the
40       private key is encrypted, an attempt will be made to decrypt it using
41       the passphrase $pass; if $pass is not provided, the empty string will
42       be used. An empty passphrase can be a handy way of providing password-
43       less access using publickey authentication.
44
45       If for any reason loading the key fails, returns undef; most of the
46       time, if loading the key fails, it's because the passphrase is incor‐
47       rect. If you first tried to read the key using an empty passphrase,
48       this might be a good time to ask the user for the actual passphrase. :)
49
50       Returns the new key object, which is blessed into the subclass denoted
51       by $key_type (either "DSA" or "RSA1").
52
53       Net::SSH::Perl::Key->keygen($key_type, $bits)
54
55       Generates a new key and returns that key. The key returned is the pri‐
56       vate key, which (presumably) contains all of the public key data, as
57       well. $bits is the number of bits in the key.
58
59       Your $key_type implementation may not support key generation; if not,
60       calling this method is a fatal error.
61
62       Returns the new key object, which is blessed into the subclass denoted
63       by $key_type (either "DSA" or "RSA1").
64
65       Net::SSH::Perl::Key->extract_public($key_type, $key_string)
66
67       Given a key string $key_string, which should be a textual representa‐
68       tion of the public portion of a key of $key_type, extracts the key
69       attributes out of that string. This is used to extract public keys out
70       of entries in known_hosts and public identity files.
71
72       Returns the new key object, which is blessed into the subclass denoted
73       by $key_type (either "DSA" or "RSA1").
74
75       $key->write_private([ $file [, $pass] ])
76
77       Writes out the private key $key to $file, and encrypts it using the
78       passphrase $pass. If $pass is not provided, the key is unencrypted, and
79       the only security protection is through filesystem protections.
80
81       If $file is not provided, returns the content that would have been
82       written to the key file.
83
84       $key->dump_public
85
86       Performs the inverse of extract_public: takes a key $key and dumps out
87       a textual representation of the public portion of the key. This is used
88       when writing public key entries to known_hosts and public identity
89       files.
90
91       Returns the textual representation.
92
93       $key->as_blob
94
95       Returns a string representation of the public portion of the key; this
96       is not the same as dump_public, which is intended to match the format
97       used in known_hosts, etc.  The return value of as_blob is used as an
98       intermediary in computing other values: the key fingerprint, the known
99       hosts representation, etc.
100
101       $key->equal($key2)
102
103       Returns true if the public portions of $key are equal to those of
104       $key2, and false otherwise. This is used when comparing server host
105       keys to keys in known_hosts.
106
107       $key->size
108
109       Returns the size (in bits) of the key $key.
110
111       $key->fingerprint([ $type ])
112
113       Returns a fingerprint of $key. The default fingerprint is a hex repre‐
114       sentation; if $type is equal to "bubblebabble", the Bubble Babble rep‐
115       resentation of the fingerprint is used instead. The former uses an MD5
116       digest of the public key, and the latter uses a SHA-1 digest.
117

AUTHOR & COPYRIGHTS

119       Please see the Net::SSH::Perl manpage for author, copyright, and
120       license information.
121
122
123
124perl v5.8.8                       2003-12-03            Net::SSH::Perl::Key(3)
Impressum