Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Convert pem to ssh-rsa

by hippo (Bishop)
on Aug 23, 2019 at 12:49 UTC ( [id://11104895]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11104895]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-23 22:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found