How to generate a .pem file for ssh?












1















I've added my ~/.ssh/id_rsa.pub to my server's 'authorized_keys' file so I can do ssh user@myserver -p port and login to the server successfully. Yet when I do



ssh-keygen -f id_rsa.pub -m 'PEM' -e > id_rsa.pem


and then use



ssh user@myserver -p port -i key.pem


I got:



Load key "key.pem": invalid format
user@myserver: Permission denied (publickey,gssapi-keyex,gssapi-with-mic)









share|improve this question
















bumped to the homepage by Community 9 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 2





    You have a PEM public key and are trying to login with it? You need a private key for that (and ssh-keygen -e -m PEM always exports the public key)

    – muru
    Mar 19 '18 at 7:36











  • Ops... Let me give it a try tmr. Sorry.

    – Aero Wang
    Mar 19 '18 at 14:03











  • @muru You should post that as an answer, because... well, it's the answer :-)

    – Philip Kendall
    Mar 19 '18 at 21:03
















1















I've added my ~/.ssh/id_rsa.pub to my server's 'authorized_keys' file so I can do ssh user@myserver -p port and login to the server successfully. Yet when I do



ssh-keygen -f id_rsa.pub -m 'PEM' -e > id_rsa.pem


and then use



ssh user@myserver -p port -i key.pem


I got:



Load key "key.pem": invalid format
user@myserver: Permission denied (publickey,gssapi-keyex,gssapi-with-mic)









share|improve this question
















bumped to the homepage by Community 9 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 2





    You have a PEM public key and are trying to login with it? You need a private key for that (and ssh-keygen -e -m PEM always exports the public key)

    – muru
    Mar 19 '18 at 7:36











  • Ops... Let me give it a try tmr. Sorry.

    – Aero Wang
    Mar 19 '18 at 14:03











  • @muru You should post that as an answer, because... well, it's the answer :-)

    – Philip Kendall
    Mar 19 '18 at 21:03














1












1








1








I've added my ~/.ssh/id_rsa.pub to my server's 'authorized_keys' file so I can do ssh user@myserver -p port and login to the server successfully. Yet when I do



ssh-keygen -f id_rsa.pub -m 'PEM' -e > id_rsa.pem


and then use



ssh user@myserver -p port -i key.pem


I got:



Load key "key.pem": invalid format
user@myserver: Permission denied (publickey,gssapi-keyex,gssapi-with-mic)









share|improve this question
















I've added my ~/.ssh/id_rsa.pub to my server's 'authorized_keys' file so I can do ssh user@myserver -p port and login to the server successfully. Yet when I do



ssh-keygen -f id_rsa.pub -m 'PEM' -e > id_rsa.pem


and then use



ssh user@myserver -p port -i key.pem


I got:



Load key "key.pem": invalid format
user@myserver: Permission denied (publickey,gssapi-keyex,gssapi-with-mic)






ubuntu ssh






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 19 '18 at 10:15









Tomasz

9,53652965




9,53652965










asked Mar 19 '18 at 7:18









Aero WangAero Wang

1114




1114





bumped to the homepage by Community 9 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 9 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.










  • 2





    You have a PEM public key and are trying to login with it? You need a private key for that (and ssh-keygen -e -m PEM always exports the public key)

    – muru
    Mar 19 '18 at 7:36











  • Ops... Let me give it a try tmr. Sorry.

    – Aero Wang
    Mar 19 '18 at 14:03











  • @muru You should post that as an answer, because... well, it's the answer :-)

    – Philip Kendall
    Mar 19 '18 at 21:03














  • 2





    You have a PEM public key and are trying to login with it? You need a private key for that (and ssh-keygen -e -m PEM always exports the public key)

    – muru
    Mar 19 '18 at 7:36











  • Ops... Let me give it a try tmr. Sorry.

    – Aero Wang
    Mar 19 '18 at 14:03











  • @muru You should post that as an answer, because... well, it's the answer :-)

    – Philip Kendall
    Mar 19 '18 at 21:03








2




2





You have a PEM public key and are trying to login with it? You need a private key for that (and ssh-keygen -e -m PEM always exports the public key)

– muru
Mar 19 '18 at 7:36





You have a PEM public key and are trying to login with it? You need a private key for that (and ssh-keygen -e -m PEM always exports the public key)

– muru
Mar 19 '18 at 7:36













Ops... Let me give it a try tmr. Sorry.

– Aero Wang
Mar 19 '18 at 14:03





Ops... Let me give it a try tmr. Sorry.

– Aero Wang
Mar 19 '18 at 14:03













@muru You should post that as an answer, because... well, it's the answer :-)

– Philip Kendall
Mar 19 '18 at 21:03





@muru You should post that as an answer, because... well, it's the answer :-)

– Philip Kendall
Mar 19 '18 at 21:03










1 Answer
1






active

oldest

votes


















0














Don't use PEM. I don't see why you would want to do that. Perhaps expand your question with some logic?



You should do:




  1. ssh-keygen

  2. ssh-copy-id user@server

  3. ssh to server






share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f432016%2fhow-to-generate-a-pem-file-for-ssh%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Don't use PEM. I don't see why you would want to do that. Perhaps expand your question with some logic?



    You should do:




    1. ssh-keygen

    2. ssh-copy-id user@server

    3. ssh to server






    share|improve this answer




























      0














      Don't use PEM. I don't see why you would want to do that. Perhaps expand your question with some logic?



      You should do:




      1. ssh-keygen

      2. ssh-copy-id user@server

      3. ssh to server






      share|improve this answer


























        0












        0








        0







        Don't use PEM. I don't see why you would want to do that. Perhaps expand your question with some logic?



        You should do:




        1. ssh-keygen

        2. ssh-copy-id user@server

        3. ssh to server






        share|improve this answer













        Don't use PEM. I don't see why you would want to do that. Perhaps expand your question with some logic?



        You should do:




        1. ssh-keygen

        2. ssh-copy-id user@server

        3. ssh to server







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 19 '18 at 21:02









        Timothy FrewTimothy Frew

        21117




        21117






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f432016%2fhow-to-generate-a-pem-file-for-ssh%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            CARDNET

            Boot-repair Failure: Unable to locate package grub-common:i386

            濃尾地震