Linux - Scp, download directory from server to local, using ssh

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












It's probably a silly thing, but I am trying to download a directory from my cloud server to my local, using scp, with the following:



scp -i ./.ssh/mykey.pem -r -p admin@11.11.251.205:/var/lib/mongodb 127.0.0.1:/var/lib/mongod


admin is of course the remote, for which I need to key, while 127.0.0.1 is the local.



I receive however the error message:



Host key verification failed.
lost connection


If I try to connect through ssh to my server using ssh -i ./.ssh/mykey.pem admin@11.11.251.205 it does work.



Could anyone point me to what I am doing wrong?







share|improve this question


























    up vote
    0
    down vote

    favorite












    It's probably a silly thing, but I am trying to download a directory from my cloud server to my local, using scp, with the following:



    scp -i ./.ssh/mykey.pem -r -p admin@11.11.251.205:/var/lib/mongodb 127.0.0.1:/var/lib/mongod


    admin is of course the remote, for which I need to key, while 127.0.0.1 is the local.



    I receive however the error message:



    Host key verification failed.
    lost connection


    If I try to connect through ssh to my server using ssh -i ./.ssh/mykey.pem admin@11.11.251.205 it does work.



    Could anyone point me to what I am doing wrong?







    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      It's probably a silly thing, but I am trying to download a directory from my cloud server to my local, using scp, with the following:



      scp -i ./.ssh/mykey.pem -r -p admin@11.11.251.205:/var/lib/mongodb 127.0.0.1:/var/lib/mongod


      admin is of course the remote, for which I need to key, while 127.0.0.1 is the local.



      I receive however the error message:



      Host key verification failed.
      lost connection


      If I try to connect through ssh to my server using ssh -i ./.ssh/mykey.pem admin@11.11.251.205 it does work.



      Could anyone point me to what I am doing wrong?







      share|improve this question














      It's probably a silly thing, but I am trying to download a directory from my cloud server to my local, using scp, with the following:



      scp -i ./.ssh/mykey.pem -r -p admin@11.11.251.205:/var/lib/mongodb 127.0.0.1:/var/lib/mongod


      admin is of course the remote, for which I need to key, while 127.0.0.1 is the local.



      I receive however the error message:



      Host key verification failed.
      lost connection


      If I try to connect through ssh to my server using ssh -i ./.ssh/mykey.pem admin@11.11.251.205 it does work.



      Could anyone point me to what I am doing wrong?









      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 31 at 1:11









      muru

      33.5k577143




      33.5k577143










      asked Jan 31 at 1:07









      jim basquiat

      1417




      1417




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          2
          down vote



          accepted










          For copying to the local server, you don't need the 127.0.0.1:. Just this will do:



          scp -i ./.ssh/mykey.pem -r -p admin@11.11.251.205:/var/lib/mongodb /var/lib/mongod


          With the 127.0.0.1:, scp makes another SSH connection to the server at 127.0.0.1 and acts as if it was copying between two remotes. The SSH server at 127.0.0.1 might be failing host key verification.






          share|improve this answer





























            up vote
            1
            down vote













            From Man page,




            scp [-346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:]file1 ... [[user@]host2:]file2




            So when you are using 127.0.0.1 at last portion, scp recognized that as host2. So then scp will try to logged in at 127.0.0.1 host with current username, based on the identity file (./.ssh/mykey.pem) and returns error, may be because there is no information about host2. So just following will work fine,



            $scp -i ./.ssh/mykey.pem -r -p admin@11.11.251.205:/var/lib/mongodb /var/lib/mongodb


            OR



            $cd /var/lib/mongodb
            $scp -i ./.ssh/mykey.pem -r -p admin@11.11.251.205:/var/lib/mongodb .





            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',
              convertImagesToLinks: false,
              noModals: false,
              showLowRepImageUploadWarning: true,
              reputationToPostImages: null,
              bindNavPrevention: true,
              postfix: "",
              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%2f420837%2flinux-scp-download-directory-from-server-to-local-using-ssh%23new-answer', 'question_page');

              );

              Post as a guest






























              2 Answers
              2






              active

              oldest

              votes








              2 Answers
              2






              active

              oldest

              votes









              active

              oldest

              votes






              active

              oldest

              votes








              up vote
              2
              down vote



              accepted










              For copying to the local server, you don't need the 127.0.0.1:. Just this will do:



              scp -i ./.ssh/mykey.pem -r -p admin@11.11.251.205:/var/lib/mongodb /var/lib/mongod


              With the 127.0.0.1:, scp makes another SSH connection to the server at 127.0.0.1 and acts as if it was copying between two remotes. The SSH server at 127.0.0.1 might be failing host key verification.






              share|improve this answer


























                up vote
                2
                down vote



                accepted










                For copying to the local server, you don't need the 127.0.0.1:. Just this will do:



                scp -i ./.ssh/mykey.pem -r -p admin@11.11.251.205:/var/lib/mongodb /var/lib/mongod


                With the 127.0.0.1:, scp makes another SSH connection to the server at 127.0.0.1 and acts as if it was copying between two remotes. The SSH server at 127.0.0.1 might be failing host key verification.






                share|improve this answer
























                  up vote
                  2
                  down vote



                  accepted







                  up vote
                  2
                  down vote



                  accepted






                  For copying to the local server, you don't need the 127.0.0.1:. Just this will do:



                  scp -i ./.ssh/mykey.pem -r -p admin@11.11.251.205:/var/lib/mongodb /var/lib/mongod


                  With the 127.0.0.1:, scp makes another SSH connection to the server at 127.0.0.1 and acts as if it was copying between two remotes. The SSH server at 127.0.0.1 might be failing host key verification.






                  share|improve this answer














                  For copying to the local server, you don't need the 127.0.0.1:. Just this will do:



                  scp -i ./.ssh/mykey.pem -r -p admin@11.11.251.205:/var/lib/mongodb /var/lib/mongod


                  With the 127.0.0.1:, scp makes another SSH connection to the server at 127.0.0.1 and acts as if it was copying between two remotes. The SSH server at 127.0.0.1 might be failing host key verification.







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Jan 31 at 1:20

























                  answered Jan 31 at 1:14









                  muru

                  33.5k577143




                  33.5k577143






















                      up vote
                      1
                      down vote













                      From Man page,




                      scp [-346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:]file1 ... [[user@]host2:]file2




                      So when you are using 127.0.0.1 at last portion, scp recognized that as host2. So then scp will try to logged in at 127.0.0.1 host with current username, based on the identity file (./.ssh/mykey.pem) and returns error, may be because there is no information about host2. So just following will work fine,



                      $scp -i ./.ssh/mykey.pem -r -p admin@11.11.251.205:/var/lib/mongodb /var/lib/mongodb


                      OR



                      $cd /var/lib/mongodb
                      $scp -i ./.ssh/mykey.pem -r -p admin@11.11.251.205:/var/lib/mongodb .





                      share|improve this answer


























                        up vote
                        1
                        down vote













                        From Man page,




                        scp [-346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:]file1 ... [[user@]host2:]file2




                        So when you are using 127.0.0.1 at last portion, scp recognized that as host2. So then scp will try to logged in at 127.0.0.1 host with current username, based on the identity file (./.ssh/mykey.pem) and returns error, may be because there is no information about host2. So just following will work fine,



                        $scp -i ./.ssh/mykey.pem -r -p admin@11.11.251.205:/var/lib/mongodb /var/lib/mongodb


                        OR



                        $cd /var/lib/mongodb
                        $scp -i ./.ssh/mykey.pem -r -p admin@11.11.251.205:/var/lib/mongodb .





                        share|improve this answer
























                          up vote
                          1
                          down vote










                          up vote
                          1
                          down vote









                          From Man page,




                          scp [-346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:]file1 ... [[user@]host2:]file2




                          So when you are using 127.0.0.1 at last portion, scp recognized that as host2. So then scp will try to logged in at 127.0.0.1 host with current username, based on the identity file (./.ssh/mykey.pem) and returns error, may be because there is no information about host2. So just following will work fine,



                          $scp -i ./.ssh/mykey.pem -r -p admin@11.11.251.205:/var/lib/mongodb /var/lib/mongodb


                          OR



                          $cd /var/lib/mongodb
                          $scp -i ./.ssh/mykey.pem -r -p admin@11.11.251.205:/var/lib/mongodb .





                          share|improve this answer














                          From Man page,




                          scp [-346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:]file1 ... [[user@]host2:]file2




                          So when you are using 127.0.0.1 at last portion, scp recognized that as host2. So then scp will try to logged in at 127.0.0.1 host with current username, based on the identity file (./.ssh/mykey.pem) and returns error, may be because there is no information about host2. So just following will work fine,



                          $scp -i ./.ssh/mykey.pem -r -p admin@11.11.251.205:/var/lib/mongodb /var/lib/mongodb


                          OR



                          $cd /var/lib/mongodb
                          $scp -i ./.ssh/mykey.pem -r -p admin@11.11.251.205:/var/lib/mongodb .






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Jan 31 at 1:26

























                          answered Jan 31 at 1:19









                          muhammad

                          480414




                          480414






















                               

                              draft saved


                              draft discarded


























                               


                              draft saved


                              draft discarded














                              StackExchange.ready(
                              function ()
                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f420837%2flinux-scp-download-directory-from-server-to-local-using-ssh%23new-answer', 'question_page');

                              );

                              Post as a guest













































































                              Popular posts from this blog

                              How to check contact read email or not when send email to Individual?

                              Displaying single band from multi-band raster using QGIS

                              How many registers does an x86_64 CPU actually have?