http://qs321.pair.com?node_id=11115164

nysus has asked for the wisdom of the Perl Monks concerning the following question:

I'm stumped trying to figure out how to use Rex to log into a remote server. The server provides me with a .pem file. I have successfully used this file to log in manually using ssh -i PEM_FILE_NAME blah@111.222.222.123.

I tried converting it to public key with ssh-keygen -y -f PEM_FILE_NAME > public.key and have the following in my RexFile:

Rex::connect( server => '111.222.222.123', user => 'my_user_name', public_key => '/home/my_user_name/public.key', );

But this isn't working. Not sure what else to try. Thanks.

$PM = "Perl Monk's";
$MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
$nysus = $PM . ' ' . $MCF;
Click here if you love Perl Monks

Replies are listed 'Best First'.
Re: Connecting to remote server with Rex using .pem file
by nysus (Parson) on Apr 07, 2020 at 15:44 UTC

    Solved

    Put this in the Rexfile:

    user 'my_user_name'; private_key '/home/my_user_name/keyfile.pem'; key_auth;

    Run like so from command line: rex -H 111.222.222.123 <task_name>

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks