in reply to Convert pem to ssh-rsa

Since I need to add this key to authorized_keys files it needs to be in a ssh-rsa format

I've not used it myself, but perhaps Net::SSH::Perl::Key->dump_public might do the trick? Just a suggestion.

Replies are listed 'Best First'.
Re^2: Convert pem to ssh-rsa
by jpsaraiva (Acolyte) on Aug 23, 2019 at 14:33 UTC
    Hello hippo, That worked! Thanks a million.
    use Crypt::PK::RSA; my $pk = Crypt::PK::RSA->new(); $pk->generate_key(256, 65537); my $private_pem = $pk->export_key_pem('private'); my $public_pem = $pk->export_key_pem('public'); use Net::SSH::Perl::Key; my $key = Net::SSH::Perl::Key->read_private('RSA', \$private_pem); say $key->dump_public;

    Output:

    ssh-rsa AAAAB...