Am I using my SSH keys correctly?












0















I recently created my keypair via ssh-keygen -t rsa -f ~/.ssh/my_keyname -C pebaken



So I looked into my .ssh folder located in my home user directory and found 2 keys one my_keyname.pub and my_keyname as well as a folder called 'authorized_keys.'



I tried using the public key my_keyname.pub while connecting to my VM I got > Disconnected: No supported authentication methods available (server sent: publickey)



I thought the public key was suppose to be the one you kept and the private key would stay on the server?



I then tried the key without any extension, put it in puttygen and immediately got > Successfully imported foreign key (OpenSSH SSH-2 private key (old PEM format)). To use this key with Putty, you need to use the "Save private" command to save it in Puttys own format.



So am I using the private key after all, because it worked and I successfully connected to my VM.










share|improve this question







New contributor




Pebaken is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

























    0















    I recently created my keypair via ssh-keygen -t rsa -f ~/.ssh/my_keyname -C pebaken



    So I looked into my .ssh folder located in my home user directory and found 2 keys one my_keyname.pub and my_keyname as well as a folder called 'authorized_keys.'



    I tried using the public key my_keyname.pub while connecting to my VM I got > Disconnected: No supported authentication methods available (server sent: publickey)



    I thought the public key was suppose to be the one you kept and the private key would stay on the server?



    I then tried the key without any extension, put it in puttygen and immediately got > Successfully imported foreign key (OpenSSH SSH-2 private key (old PEM format)). To use this key with Putty, you need to use the "Save private" command to save it in Puttys own format.



    So am I using the private key after all, because it worked and I successfully connected to my VM.










    share|improve this question







    New contributor




    Pebaken is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.























      0












      0








      0








      I recently created my keypair via ssh-keygen -t rsa -f ~/.ssh/my_keyname -C pebaken



      So I looked into my .ssh folder located in my home user directory and found 2 keys one my_keyname.pub and my_keyname as well as a folder called 'authorized_keys.'



      I tried using the public key my_keyname.pub while connecting to my VM I got > Disconnected: No supported authentication methods available (server sent: publickey)



      I thought the public key was suppose to be the one you kept and the private key would stay on the server?



      I then tried the key without any extension, put it in puttygen and immediately got > Successfully imported foreign key (OpenSSH SSH-2 private key (old PEM format)). To use this key with Putty, you need to use the "Save private" command to save it in Puttys own format.



      So am I using the private key after all, because it worked and I successfully connected to my VM.










      share|improve this question







      New contributor




      Pebaken is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.












      I recently created my keypair via ssh-keygen -t rsa -f ~/.ssh/my_keyname -C pebaken



      So I looked into my .ssh folder located in my home user directory and found 2 keys one my_keyname.pub and my_keyname as well as a folder called 'authorized_keys.'



      I tried using the public key my_keyname.pub while connecting to my VM I got > Disconnected: No supported authentication methods available (server sent: publickey)



      I thought the public key was suppose to be the one you kept and the private key would stay on the server?



      I then tried the key without any extension, put it in puttygen and immediately got > Successfully imported foreign key (OpenSSH SSH-2 private key (old PEM format)). To use this key with Putty, you need to use the "Save private" command to save it in Puttys own format.



      So am I using the private key after all, because it worked and I successfully connected to my VM.







      ubuntu ssh






      share|improve this question







      New contributor




      Pebaken is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      share|improve this question







      New contributor




      Pebaken is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      share|improve this question




      share|improve this question






      New contributor




      Pebaken is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 5 hours ago









      PebakenPebaken

      1




      1




      New contributor




      Pebaken is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      Pebaken is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      Pebaken is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






















          2 Answers
          2






          active

          oldest

          votes


















          0














          The public key is for copying to ~/.ssh/authorized_keys (which is a file, not a directory) on the remote hosts you will be connecting to.



          The private key is for connecting with from your local system.



          Related:




          • How to ssh to remote server using a private key?






          share|improve this answer
























          • Sorry I did mean file, not folder.I'm confused as initially, I believed you needed the public key to access a VM from the outside? The private key would stay on the server.

            – Pebaken
            5 hours ago











          • @Pebaken The public key is used to prove you possess the private key thus confirming you are authorized so long as your public key is listed inside authorized_keys. The client authenticates the server via known_hosts

            – jdwolf
            1 hour ago





















          0














          It's in the name.



          The private key is the one you keep to yourself, never share this with anyone and ideally keep it encrypted with a passphrase.



          The public key can be distributed anywhere, you can publish it in plain text anywhere.



          The public key needs to go on the remote server to confirm you have an appropriate key, the private key should never leave your local environment.



          The public key can be derived from the private key.



          When authenticating your ssh client will offer a public key (which it will derive from the local public key) to the remote server. The server will confirm that public key is able to authenticate to it and offer a challenge that will not be answerable unless you have the private key. Your client answers the challenge with your private key and the remote server lets you login.






          share|improve this answer








          New contributor




          lyte is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
          Check out our Code of Conduct.




















            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
            });


            }
            });






            Pebaken is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f505401%2fam-i-using-my-ssh-keys-correctly%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            The public key is for copying to ~/.ssh/authorized_keys (which is a file, not a directory) on the remote hosts you will be connecting to.



            The private key is for connecting with from your local system.



            Related:




            • How to ssh to remote server using a private key?






            share|improve this answer
























            • Sorry I did mean file, not folder.I'm confused as initially, I believed you needed the public key to access a VM from the outside? The private key would stay on the server.

              – Pebaken
              5 hours ago











            • @Pebaken The public key is used to prove you possess the private key thus confirming you are authorized so long as your public key is listed inside authorized_keys. The client authenticates the server via known_hosts

              – jdwolf
              1 hour ago


















            0














            The public key is for copying to ~/.ssh/authorized_keys (which is a file, not a directory) on the remote hosts you will be connecting to.



            The private key is for connecting with from your local system.



            Related:




            • How to ssh to remote server using a private key?






            share|improve this answer
























            • Sorry I did mean file, not folder.I'm confused as initially, I believed you needed the public key to access a VM from the outside? The private key would stay on the server.

              – Pebaken
              5 hours ago











            • @Pebaken The public key is used to prove you possess the private key thus confirming you are authorized so long as your public key is listed inside authorized_keys. The client authenticates the server via known_hosts

              – jdwolf
              1 hour ago
















            0












            0








            0







            The public key is for copying to ~/.ssh/authorized_keys (which is a file, not a directory) on the remote hosts you will be connecting to.



            The private key is for connecting with from your local system.



            Related:




            • How to ssh to remote server using a private key?






            share|improve this answer













            The public key is for copying to ~/.ssh/authorized_keys (which is a file, not a directory) on the remote hosts you will be connecting to.



            The private key is for connecting with from your local system.



            Related:




            • How to ssh to remote server using a private key?







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 5 hours ago









            KusalanandaKusalananda

            134k17255418




            134k17255418













            • Sorry I did mean file, not folder.I'm confused as initially, I believed you needed the public key to access a VM from the outside? The private key would stay on the server.

              – Pebaken
              5 hours ago











            • @Pebaken The public key is used to prove you possess the private key thus confirming you are authorized so long as your public key is listed inside authorized_keys. The client authenticates the server via known_hosts

              – jdwolf
              1 hour ago





















            • Sorry I did mean file, not folder.I'm confused as initially, I believed you needed the public key to access a VM from the outside? The private key would stay on the server.

              – Pebaken
              5 hours ago











            • @Pebaken The public key is used to prove you possess the private key thus confirming you are authorized so long as your public key is listed inside authorized_keys. The client authenticates the server via known_hosts

              – jdwolf
              1 hour ago



















            Sorry I did mean file, not folder.I'm confused as initially, I believed you needed the public key to access a VM from the outside? The private key would stay on the server.

            – Pebaken
            5 hours ago





            Sorry I did mean file, not folder.I'm confused as initially, I believed you needed the public key to access a VM from the outside? The private key would stay on the server.

            – Pebaken
            5 hours ago













            @Pebaken The public key is used to prove you possess the private key thus confirming you are authorized so long as your public key is listed inside authorized_keys. The client authenticates the server via known_hosts

            – jdwolf
            1 hour ago







            @Pebaken The public key is used to prove you possess the private key thus confirming you are authorized so long as your public key is listed inside authorized_keys. The client authenticates the server via known_hosts

            – jdwolf
            1 hour ago















            0














            It's in the name.



            The private key is the one you keep to yourself, never share this with anyone and ideally keep it encrypted with a passphrase.



            The public key can be distributed anywhere, you can publish it in plain text anywhere.



            The public key needs to go on the remote server to confirm you have an appropriate key, the private key should never leave your local environment.



            The public key can be derived from the private key.



            When authenticating your ssh client will offer a public key (which it will derive from the local public key) to the remote server. The server will confirm that public key is able to authenticate to it and offer a challenge that will not be answerable unless you have the private key. Your client answers the challenge with your private key and the remote server lets you login.






            share|improve this answer








            New contributor




            lyte is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
            Check out our Code of Conduct.

























              0














              It's in the name.



              The private key is the one you keep to yourself, never share this with anyone and ideally keep it encrypted with a passphrase.



              The public key can be distributed anywhere, you can publish it in plain text anywhere.



              The public key needs to go on the remote server to confirm you have an appropriate key, the private key should never leave your local environment.



              The public key can be derived from the private key.



              When authenticating your ssh client will offer a public key (which it will derive from the local public key) to the remote server. The server will confirm that public key is able to authenticate to it and offer a challenge that will not be answerable unless you have the private key. Your client answers the challenge with your private key and the remote server lets you login.






              share|improve this answer








              New contributor




              lyte is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
              Check out our Code of Conduct.























                0












                0








                0







                It's in the name.



                The private key is the one you keep to yourself, never share this with anyone and ideally keep it encrypted with a passphrase.



                The public key can be distributed anywhere, you can publish it in plain text anywhere.



                The public key needs to go on the remote server to confirm you have an appropriate key, the private key should never leave your local environment.



                The public key can be derived from the private key.



                When authenticating your ssh client will offer a public key (which it will derive from the local public key) to the remote server. The server will confirm that public key is able to authenticate to it and offer a challenge that will not be answerable unless you have the private key. Your client answers the challenge with your private key and the remote server lets you login.






                share|improve this answer








                New contributor




                lyte is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.










                It's in the name.



                The private key is the one you keep to yourself, never share this with anyone and ideally keep it encrypted with a passphrase.



                The public key can be distributed anywhere, you can publish it in plain text anywhere.



                The public key needs to go on the remote server to confirm you have an appropriate key, the private key should never leave your local environment.



                The public key can be derived from the private key.



                When authenticating your ssh client will offer a public key (which it will derive from the local public key) to the remote server. The server will confirm that public key is able to authenticate to it and offer a challenge that will not be answerable unless you have the private key. Your client answers the challenge with your private key and the remote server lets you login.







                share|improve this answer








                New contributor




                lyte is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                share|improve this answer



                share|improve this answer






                New contributor




                lyte is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.









                answered 1 hour ago









                lytelyte

                1012




                1012




                New contributor




                lyte is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.





                New contributor





                lyte is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






                lyte is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
                Check out our Code of Conduct.






















                    Pebaken is a new contributor. Be nice, and check out our Code of Conduct.










                    draft saved

                    draft discarded


















                    Pebaken is a new contributor. Be nice, and check out our Code of Conduct.













                    Pebaken is a new contributor. Be nice, and check out our Code of Conduct.












                    Pebaken is a new contributor. Be nice, and check out our Code of Conduct.
















                    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%2f505401%2fam-i-using-my-ssh-keys-correctly%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

                    濃尾地震