
Net::SSH::AuthorizedKeysFile - Read and modify ssh's authorized_keys files

use Net::SSH::AuthorizedKeysFile;
# Reads $HOME/.ssh/authorized_keys by default
my $akf = Net::SSH::AuthorizedKeysFile->new();
# Iterate over entries
for my $key ($akf->keys()) {
print $key->keylen(), "\n";
}
# Modify entries:
for my $key ($akf->keys()) {
$key->option("from", 'quack@quack.com');
$key->keylen(1025);
}
# Save changes back to $HOME/.ssh/authorized_keys
$akf->save();

Net::SSH::AuthorizedKeysFile reads and modifies authorized_keys files. authorized_keys files contain public keys and meta information to be used by ssh on the remote host to let users in without having to type their password.

newCreates a new Net::SSH::AuthorizedKeysFile object and reads in the authorized_keys file. The filename defaults to $HOME/.ssh/authorized_keys unless overridden with
Net::SSH::AuthorizedKeysFile->new( file => "/path/other_authkeys_file" );
keysReturns a list of Net::SSH::AuthorizedKey objects. Methods are described in Net::SSH::AuthorizedKey.
as_stringString representation of all keys, ultimately the content that gets written out when calling the save() method.
saveWrite changes back to the authorized_keys file.

Copyright 2005 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.

2005, Mike Schilli <m@perlmeister.com>