To use ssh-id-copy do you need both id_rsa.pub and id_rsa?












17















I am trying to setup a second access ssh key for a friend. He sent me his id_rsa.pub.



ssh-copy-id -i id_rsa.pub root@123.123.123.123
/usr/local/bin/ssh-copy-id: ERROR: failed to open ID file './id_rsa': No such file or directory


Do I need him to send me both files?










share|improve this question













migrated from serverfault.com Feb 6 '15 at 8:15


This question came from our site for system and network administrators.














  • 1





    The .pub is sufficient. And keep in mind that you always keep your private key secrete (at all times!). To add a new key you can simple append the content of .pub to your authorized_keys.

    – deagh
    Feb 6 '15 at 7:04






  • 2





    @deaghYou don't need to keep a private key secret, you need to keep it secure.

    – Iain
    Feb 6 '15 at 7:20











  • The ssh-copy-id script here doesn't appear to emit that particular error message. I notice your ssh-copy-id script is in /usr/local/bin. It may be different from the commonly-used version of the command.

    – Kenster
    Feb 6 '15 at 16:19
















17















I am trying to setup a second access ssh key for a friend. He sent me his id_rsa.pub.



ssh-copy-id -i id_rsa.pub root@123.123.123.123
/usr/local/bin/ssh-copy-id: ERROR: failed to open ID file './id_rsa': No such file or directory


Do I need him to send me both files?










share|improve this question













migrated from serverfault.com Feb 6 '15 at 8:15


This question came from our site for system and network administrators.














  • 1





    The .pub is sufficient. And keep in mind that you always keep your private key secrete (at all times!). To add a new key you can simple append the content of .pub to your authorized_keys.

    – deagh
    Feb 6 '15 at 7:04






  • 2





    @deaghYou don't need to keep a private key secret, you need to keep it secure.

    – Iain
    Feb 6 '15 at 7:20











  • The ssh-copy-id script here doesn't appear to emit that particular error message. I notice your ssh-copy-id script is in /usr/local/bin. It may be different from the commonly-used version of the command.

    – Kenster
    Feb 6 '15 at 16:19














17












17








17


1






I am trying to setup a second access ssh key for a friend. He sent me his id_rsa.pub.



ssh-copy-id -i id_rsa.pub root@123.123.123.123
/usr/local/bin/ssh-copy-id: ERROR: failed to open ID file './id_rsa': No such file or directory


Do I need him to send me both files?










share|improve this question














I am trying to setup a second access ssh key for a friend. He sent me his id_rsa.pub.



ssh-copy-id -i id_rsa.pub root@123.123.123.123
/usr/local/bin/ssh-copy-id: ERROR: failed to open ID file './id_rsa': No such file or directory


Do I need him to send me both files?







linux centos ssh ssh-keys






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 6 '15 at 6:30







user269023











migrated from serverfault.com Feb 6 '15 at 8:15


This question came from our site for system and network administrators.









migrated from serverfault.com Feb 6 '15 at 8:15


This question came from our site for system and network administrators.










  • 1





    The .pub is sufficient. And keep in mind that you always keep your private key secrete (at all times!). To add a new key you can simple append the content of .pub to your authorized_keys.

    – deagh
    Feb 6 '15 at 7:04






  • 2





    @deaghYou don't need to keep a private key secret, you need to keep it secure.

    – Iain
    Feb 6 '15 at 7:20











  • The ssh-copy-id script here doesn't appear to emit that particular error message. I notice your ssh-copy-id script is in /usr/local/bin. It may be different from the commonly-used version of the command.

    – Kenster
    Feb 6 '15 at 16:19














  • 1





    The .pub is sufficient. And keep in mind that you always keep your private key secrete (at all times!). To add a new key you can simple append the content of .pub to your authorized_keys.

    – deagh
    Feb 6 '15 at 7:04






  • 2





    @deaghYou don't need to keep a private key secret, you need to keep it secure.

    – Iain
    Feb 6 '15 at 7:20











  • The ssh-copy-id script here doesn't appear to emit that particular error message. I notice your ssh-copy-id script is in /usr/local/bin. It may be different from the commonly-used version of the command.

    – Kenster
    Feb 6 '15 at 16:19








1




1





The .pub is sufficient. And keep in mind that you always keep your private key secrete (at all times!). To add a new key you can simple append the content of .pub to your authorized_keys.

– deagh
Feb 6 '15 at 7:04





The .pub is sufficient. And keep in mind that you always keep your private key secrete (at all times!). To add a new key you can simple append the content of .pub to your authorized_keys.

– deagh
Feb 6 '15 at 7:04




2




2





@deaghYou don't need to keep a private key secret, you need to keep it secure.

– Iain
Feb 6 '15 at 7:20





@deaghYou don't need to keep a private key secret, you need to keep it secure.

– Iain
Feb 6 '15 at 7:20













The ssh-copy-id script here doesn't appear to emit that particular error message. I notice your ssh-copy-id script is in /usr/local/bin. It may be different from the commonly-used version of the command.

– Kenster
Feb 6 '15 at 16:19





The ssh-copy-id script here doesn't appear to emit that particular error message. I notice your ssh-copy-id script is in /usr/local/bin. It may be different from the commonly-used version of the command.

– Kenster
Feb 6 '15 at 16:19










5 Answers
5






active

oldest

votes


















8














The ssh-copy-id command from OpenSSH fails if there is no private key file with the same name available, because it tries to login with the specified key to check if it is already present on the remote server.



In recent versions you can override this behavior with the -f switch ("Forced mode").



From the man page:




-f


    Forced mode: doesn't check if the keys are present on the
    remote server.  This means that it does not need the private key.  Of
    course, this can result in more than one copy of the key being installed
    on the remote system.






share|improve this answer

































    5














    The .pub is sufficient. You are not in the correct folder.



    You can try this :



    ssh-copy-id -i /root/.ssh/id_rsa.pub root@123.123.123.123


    (for the root user : not recommended, it's just an example).



    This file is under the .ssh folder on the user folder.






    share|improve this answer





















    • 2





      On mac it needs the -f if you don't have the private key as well, I think

      – Stevie G
      Aug 6 '16 at 9:54



















    2














    This has been reported as OpenSSH bug #2110.






    share|improve this answer































      1














      As mentioned here this is a bug.



      Anyway you can simply create an empty file to make it work. In your case:



      $ touch ./id_rsa
      $ ssh-copy-id -i id_rsa.pub root@123.123.123.123


      I had the same issue and this worked for me 👍






      share|improve this answer































        -1














        it works for me the question is when it ask "Enter file in which to save the key (/Users/xiaoyu/.ssh/id_rsa):" u should type id_rsa



        and use commande "ssh-copy-id -i ~/.ssh/id_rsa.pub polytech@192.168.0.102"






        share|improve this answer























          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "3"
          };
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          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%2fsuperuser.com%2fquestions%2f874406%2fto-use-ssh-id-copy-do-you-need-both-id-rsa-pub-and-id-rsa%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown
























          5 Answers
          5






          active

          oldest

          votes








          5 Answers
          5






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          8














          The ssh-copy-id command from OpenSSH fails if there is no private key file with the same name available, because it tries to login with the specified key to check if it is already present on the remote server.



          In recent versions you can override this behavior with the -f switch ("Forced mode").



          From the man page:




          -f


            Forced mode: doesn't check if the keys are present on the
            remote server.  This means that it does not need the private key.  Of
            course, this can result in more than one copy of the key being installed
            on the remote system.






          share|improve this answer






























            8














            The ssh-copy-id command from OpenSSH fails if there is no private key file with the same name available, because it tries to login with the specified key to check if it is already present on the remote server.



            In recent versions you can override this behavior with the -f switch ("Forced mode").



            From the man page:




            -f


              Forced mode: doesn't check if the keys are present on the
              remote server.  This means that it does not need the private key.  Of
              course, this can result in more than one copy of the key being installed
              on the remote system.






            share|improve this answer




























              8












              8








              8







              The ssh-copy-id command from OpenSSH fails if there is no private key file with the same name available, because it tries to login with the specified key to check if it is already present on the remote server.



              In recent versions you can override this behavior with the -f switch ("Forced mode").



              From the man page:




              -f


                Forced mode: doesn't check if the keys are present on the
                remote server.  This means that it does not need the private key.  Of
                course, this can result in more than one copy of the key being installed
                on the remote system.






              share|improve this answer















              The ssh-copy-id command from OpenSSH fails if there is no private key file with the same name available, because it tries to login with the specified key to check if it is already present on the remote server.



              In recent versions you can override this behavior with the -f switch ("Forced mode").



              From the man page:




              -f


                Forced mode: doesn't check if the keys are present on the
                remote server.  This means that it does not need the private key.  Of
                course, this can result in more than one copy of the key being installed
                on the remote system.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Jan 13 at 2:44









              Scott

              15.7k113890




              15.7k113890










              answered Jun 10 '16 at 18:26









              Dario SeidlDario Seidl

              2,14611318




              2,14611318

























                  5














                  The .pub is sufficient. You are not in the correct folder.



                  You can try this :



                  ssh-copy-id -i /root/.ssh/id_rsa.pub root@123.123.123.123


                  (for the root user : not recommended, it's just an example).



                  This file is under the .ssh folder on the user folder.






                  share|improve this answer





















                  • 2





                    On mac it needs the -f if you don't have the private key as well, I think

                    – Stevie G
                    Aug 6 '16 at 9:54
















                  5














                  The .pub is sufficient. You are not in the correct folder.



                  You can try this :



                  ssh-copy-id -i /root/.ssh/id_rsa.pub root@123.123.123.123


                  (for the root user : not recommended, it's just an example).



                  This file is under the .ssh folder on the user folder.






                  share|improve this answer





















                  • 2





                    On mac it needs the -f if you don't have the private key as well, I think

                    – Stevie G
                    Aug 6 '16 at 9:54














                  5












                  5








                  5







                  The .pub is sufficient. You are not in the correct folder.



                  You can try this :



                  ssh-copy-id -i /root/.ssh/id_rsa.pub root@123.123.123.123


                  (for the root user : not recommended, it's just an example).



                  This file is under the .ssh folder on the user folder.






                  share|improve this answer















                  The .pub is sufficient. You are not in the correct folder.



                  You can try this :



                  ssh-copy-id -i /root/.ssh/id_rsa.pub root@123.123.123.123


                  (for the root user : not recommended, it's just an example).



                  This file is under the .ssh folder on the user folder.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Mar 19 '16 at 8:15









                  Stevie G

                  1153317




                  1153317










                  answered Feb 6 '15 at 14:10









                  Jérémy MunozJérémy Munoz

                  1591




                  1591








                  • 2





                    On mac it needs the -f if you don't have the private key as well, I think

                    – Stevie G
                    Aug 6 '16 at 9:54














                  • 2





                    On mac it needs the -f if you don't have the private key as well, I think

                    – Stevie G
                    Aug 6 '16 at 9:54








                  2




                  2





                  On mac it needs the -f if you don't have the private key as well, I think

                  – Stevie G
                  Aug 6 '16 at 9:54





                  On mac it needs the -f if you don't have the private key as well, I think

                  – Stevie G
                  Aug 6 '16 at 9:54











                  2














                  This has been reported as OpenSSH bug #2110.






                  share|improve this answer




























                    2














                    This has been reported as OpenSSH bug #2110.






                    share|improve this answer


























                      2












                      2








                      2







                      This has been reported as OpenSSH bug #2110.






                      share|improve this answer













                      This has been reported as OpenSSH bug #2110.







                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Feb 16 '16 at 0:01









                      Mihai CapotăMihai Capotă

                      633711




                      633711























                          1














                          As mentioned here this is a bug.



                          Anyway you can simply create an empty file to make it work. In your case:



                          $ touch ./id_rsa
                          $ ssh-copy-id -i id_rsa.pub root@123.123.123.123


                          I had the same issue and this worked for me 👍






                          share|improve this answer




























                            1














                            As mentioned here this is a bug.



                            Anyway you can simply create an empty file to make it work. In your case:



                            $ touch ./id_rsa
                            $ ssh-copy-id -i id_rsa.pub root@123.123.123.123


                            I had the same issue and this worked for me 👍






                            share|improve this answer


























                              1












                              1








                              1







                              As mentioned here this is a bug.



                              Anyway you can simply create an empty file to make it work. In your case:



                              $ touch ./id_rsa
                              $ ssh-copy-id -i id_rsa.pub root@123.123.123.123


                              I had the same issue and this worked for me 👍






                              share|improve this answer













                              As mentioned here this is a bug.



                              Anyway you can simply create an empty file to make it work. In your case:



                              $ touch ./id_rsa
                              $ ssh-copy-id -i id_rsa.pub root@123.123.123.123


                              I had the same issue and this worked for me 👍







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Nov 6 '17 at 11:22









                              jawirajawira

                              1111




                              1111























                                  -1














                                  it works for me the question is when it ask "Enter file in which to save the key (/Users/xiaoyu/.ssh/id_rsa):" u should type id_rsa



                                  and use commande "ssh-copy-id -i ~/.ssh/id_rsa.pub polytech@192.168.0.102"






                                  share|improve this answer




























                                    -1














                                    it works for me the question is when it ask "Enter file in which to save the key (/Users/xiaoyu/.ssh/id_rsa):" u should type id_rsa



                                    and use commande "ssh-copy-id -i ~/.ssh/id_rsa.pub polytech@192.168.0.102"






                                    share|improve this answer


























                                      -1












                                      -1








                                      -1







                                      it works for me the question is when it ask "Enter file in which to save the key (/Users/xiaoyu/.ssh/id_rsa):" u should type id_rsa



                                      and use commande "ssh-copy-id -i ~/.ssh/id_rsa.pub polytech@192.168.0.102"






                                      share|improve this answer













                                      it works for me the question is when it ask "Enter file in which to save the key (/Users/xiaoyu/.ssh/id_rsa):" u should type id_rsa



                                      and use commande "ssh-copy-id -i ~/.ssh/id_rsa.pub polytech@192.168.0.102"







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Jan 13 at 0:14









                                      user984431user984431

                                      1




                                      1






























                                          draft saved

                                          draft discarded




















































                                          Thanks for contributing an answer to Super User!


                                          • 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%2fsuperuser.com%2fquestions%2f874406%2fto-use-ssh-id-copy-do-you-need-both-id-rsa-pub-and-id-rsa%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

                                          How to reconfigure Docker Trusted Registry 2.x.x to use CEPH FS mount instead of NFS and other traditional...

                                          is 'sed' thread safe

                                          How to make a Squid Proxy server?