How to copy files from a double remote server on a local machine

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











up vote
0
down vote

favorite
1












I have some files on a server that I'd like to copy on my local machine. The problem is that I can't directly connect to the remote machine, so I need to connect to an intermediate server first, then I can connect to the destination server via the intermediate one. Is there any way to copy the files directly from the destination server to the local machine and somehow bypass the intermediate server?



Thanks







share|improve this question




















  • How are you connecting to the intermediate? If you are using ssh you can use something called port forwarding to copy the files. It'll look like you are copying directly from the remote but you'll actually be tunneling through the intermediate. The direct path is probably not possible.
    – B Layer
    Oct 16 '17 at 10:11











  • @BLayer Thanks a lot for the reply. Yes, I am using ssh to connect to the intermediate server.
    – Eman
    Oct 16 '17 at 10:17










  • It worked? I see you accepted. That was fast. :)
    – B Layer
    Oct 16 '17 at 10:21










  • @BLayer Yup, thanks:)
    – Eman
    Oct 16 '17 at 10:21










  • Awesome. You're welcome.
    – B Layer
    Oct 16 '17 at 10:21














up vote
0
down vote

favorite
1












I have some files on a server that I'd like to copy on my local machine. The problem is that I can't directly connect to the remote machine, so I need to connect to an intermediate server first, then I can connect to the destination server via the intermediate one. Is there any way to copy the files directly from the destination server to the local machine and somehow bypass the intermediate server?



Thanks







share|improve this question




















  • How are you connecting to the intermediate? If you are using ssh you can use something called port forwarding to copy the files. It'll look like you are copying directly from the remote but you'll actually be tunneling through the intermediate. The direct path is probably not possible.
    – B Layer
    Oct 16 '17 at 10:11











  • @BLayer Thanks a lot for the reply. Yes, I am using ssh to connect to the intermediate server.
    – Eman
    Oct 16 '17 at 10:17










  • It worked? I see you accepted. That was fast. :)
    – B Layer
    Oct 16 '17 at 10:21










  • @BLayer Yup, thanks:)
    – Eman
    Oct 16 '17 at 10:21










  • Awesome. You're welcome.
    – B Layer
    Oct 16 '17 at 10:21












up vote
0
down vote

favorite
1









up vote
0
down vote

favorite
1






1





I have some files on a server that I'd like to copy on my local machine. The problem is that I can't directly connect to the remote machine, so I need to connect to an intermediate server first, then I can connect to the destination server via the intermediate one. Is there any way to copy the files directly from the destination server to the local machine and somehow bypass the intermediate server?



Thanks







share|improve this question












I have some files on a server that I'd like to copy on my local machine. The problem is that I can't directly connect to the remote machine, so I need to connect to an intermediate server first, then I can connect to the destination server via the intermediate one. Is there any way to copy the files directly from the destination server to the local machine and somehow bypass the intermediate server?



Thanks









share|improve this question











share|improve this question




share|improve this question










asked Oct 16 '17 at 10:05









Eman

31




31











  • How are you connecting to the intermediate? If you are using ssh you can use something called port forwarding to copy the files. It'll look like you are copying directly from the remote but you'll actually be tunneling through the intermediate. The direct path is probably not possible.
    – B Layer
    Oct 16 '17 at 10:11











  • @BLayer Thanks a lot for the reply. Yes, I am using ssh to connect to the intermediate server.
    – Eman
    Oct 16 '17 at 10:17










  • It worked? I see you accepted. That was fast. :)
    – B Layer
    Oct 16 '17 at 10:21










  • @BLayer Yup, thanks:)
    – Eman
    Oct 16 '17 at 10:21










  • Awesome. You're welcome.
    – B Layer
    Oct 16 '17 at 10:21
















  • How are you connecting to the intermediate? If you are using ssh you can use something called port forwarding to copy the files. It'll look like you are copying directly from the remote but you'll actually be tunneling through the intermediate. The direct path is probably not possible.
    – B Layer
    Oct 16 '17 at 10:11











  • @BLayer Thanks a lot for the reply. Yes, I am using ssh to connect to the intermediate server.
    – Eman
    Oct 16 '17 at 10:17










  • It worked? I see you accepted. That was fast. :)
    – B Layer
    Oct 16 '17 at 10:21










  • @BLayer Yup, thanks:)
    – Eman
    Oct 16 '17 at 10:21










  • Awesome. You're welcome.
    – B Layer
    Oct 16 '17 at 10:21















How are you connecting to the intermediate? If you are using ssh you can use something called port forwarding to copy the files. It'll look like you are copying directly from the remote but you'll actually be tunneling through the intermediate. The direct path is probably not possible.
– B Layer
Oct 16 '17 at 10:11





How are you connecting to the intermediate? If you are using ssh you can use something called port forwarding to copy the files. It'll look like you are copying directly from the remote but you'll actually be tunneling through the intermediate. The direct path is probably not possible.
– B Layer
Oct 16 '17 at 10:11













@BLayer Thanks a lot for the reply. Yes, I am using ssh to connect to the intermediate server.
– Eman
Oct 16 '17 at 10:17




@BLayer Thanks a lot for the reply. Yes, I am using ssh to connect to the intermediate server.
– Eman
Oct 16 '17 at 10:17












It worked? I see you accepted. That was fast. :)
– B Layer
Oct 16 '17 at 10:21




It worked? I see you accepted. That was fast. :)
– B Layer
Oct 16 '17 at 10:21












@BLayer Yup, thanks:)
– Eman
Oct 16 '17 at 10:21




@BLayer Yup, thanks:)
– Eman
Oct 16 '17 at 10:21












Awesome. You're welcome.
– B Layer
Oct 16 '17 at 10:21




Awesome. You're welcome.
– B Layer
Oct 16 '17 at 10:21










2 Answers
2






active

oldest

votes

















up vote
0
down vote



accepted










Going the direct route is probably not possible. But if you are able to log into the intermediate with ssh and then from there log into the remote with ssh then you can use something called local port forwarding to copy the files on your local machine with scp. It'll look like you are copying directly from the remote but you'll actually be tunneling through the intermediate.



Try the following on two separate terminals (command lines, shells, etc.)



Terminal 1:



# set up 'local port forwarding'
ssh -v -T -N -L 2222:remote:22 username@intermediate


Terminal 2:



# do your scp command(s) like this example
scp -P 2222 localhost:/path/to/file .


Substitute appropriate hostnames or IP addresses for remote and intermediate.



In the scp command /path/to/file is the path on the remote server.






share|improve this answer





























    up vote
    1
    down vote













    You don't need port forwarding, you can do it with ProxyCommand. Add something like this to ~/.ssh/config:



    Host some_name
    Hostname internal.example.com
    User internal_user
    ProxyCommand ssh -A -q -l %r -W %h:%p external.example.com


    This will allow you to ssh to the internal machine with ssh some_name, use scp, etc.






    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%2f398370%2fhow-to-copy-files-from-a-double-remote-server-on-a-local-machine%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
      0
      down vote



      accepted










      Going the direct route is probably not possible. But if you are able to log into the intermediate with ssh and then from there log into the remote with ssh then you can use something called local port forwarding to copy the files on your local machine with scp. It'll look like you are copying directly from the remote but you'll actually be tunneling through the intermediate.



      Try the following on two separate terminals (command lines, shells, etc.)



      Terminal 1:



      # set up 'local port forwarding'
      ssh -v -T -N -L 2222:remote:22 username@intermediate


      Terminal 2:



      # do your scp command(s) like this example
      scp -P 2222 localhost:/path/to/file .


      Substitute appropriate hostnames or IP addresses for remote and intermediate.



      In the scp command /path/to/file is the path on the remote server.






      share|improve this answer


























        up vote
        0
        down vote



        accepted










        Going the direct route is probably not possible. But if you are able to log into the intermediate with ssh and then from there log into the remote with ssh then you can use something called local port forwarding to copy the files on your local machine with scp. It'll look like you are copying directly from the remote but you'll actually be tunneling through the intermediate.



        Try the following on two separate terminals (command lines, shells, etc.)



        Terminal 1:



        # set up 'local port forwarding'
        ssh -v -T -N -L 2222:remote:22 username@intermediate


        Terminal 2:



        # do your scp command(s) like this example
        scp -P 2222 localhost:/path/to/file .


        Substitute appropriate hostnames or IP addresses for remote and intermediate.



        In the scp command /path/to/file is the path on the remote server.






        share|improve this answer
























          up vote
          0
          down vote



          accepted







          up vote
          0
          down vote



          accepted






          Going the direct route is probably not possible. But if you are able to log into the intermediate with ssh and then from there log into the remote with ssh then you can use something called local port forwarding to copy the files on your local machine with scp. It'll look like you are copying directly from the remote but you'll actually be tunneling through the intermediate.



          Try the following on two separate terminals (command lines, shells, etc.)



          Terminal 1:



          # set up 'local port forwarding'
          ssh -v -T -N -L 2222:remote:22 username@intermediate


          Terminal 2:



          # do your scp command(s) like this example
          scp -P 2222 localhost:/path/to/file .


          Substitute appropriate hostnames or IP addresses for remote and intermediate.



          In the scp command /path/to/file is the path on the remote server.






          share|improve this answer














          Going the direct route is probably not possible. But if you are able to log into the intermediate with ssh and then from there log into the remote with ssh then you can use something called local port forwarding to copy the files on your local machine with scp. It'll look like you are copying directly from the remote but you'll actually be tunneling through the intermediate.



          Try the following on two separate terminals (command lines, shells, etc.)



          Terminal 1:



          # set up 'local port forwarding'
          ssh -v -T -N -L 2222:remote:22 username@intermediate


          Terminal 2:



          # do your scp command(s) like this example
          scp -P 2222 localhost:/path/to/file .


          Substitute appropriate hostnames or IP addresses for remote and intermediate.



          In the scp command /path/to/file is the path on the remote server.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Oct 16 '17 at 10:30

























          answered Oct 16 '17 at 10:17









          B Layer

          3,9241525




          3,9241525






















              up vote
              1
              down vote













              You don't need port forwarding, you can do it with ProxyCommand. Add something like this to ~/.ssh/config:



              Host some_name
              Hostname internal.example.com
              User internal_user
              ProxyCommand ssh -A -q -l %r -W %h:%p external.example.com


              This will allow you to ssh to the internal machine with ssh some_name, use scp, etc.






              share|improve this answer
























                up vote
                1
                down vote













                You don't need port forwarding, you can do it with ProxyCommand. Add something like this to ~/.ssh/config:



                Host some_name
                Hostname internal.example.com
                User internal_user
                ProxyCommand ssh -A -q -l %r -W %h:%p external.example.com


                This will allow you to ssh to the internal machine with ssh some_name, use scp, etc.






                share|improve this answer






















                  up vote
                  1
                  down vote










                  up vote
                  1
                  down vote









                  You don't need port forwarding, you can do it with ProxyCommand. Add something like this to ~/.ssh/config:



                  Host some_name
                  Hostname internal.example.com
                  User internal_user
                  ProxyCommand ssh -A -q -l %r -W %h:%p external.example.com


                  This will allow you to ssh to the internal machine with ssh some_name, use scp, etc.






                  share|improve this answer












                  You don't need port forwarding, you can do it with ProxyCommand. Add something like this to ~/.ssh/config:



                  Host some_name
                  Hostname internal.example.com
                  User internal_user
                  ProxyCommand ssh -A -q -l %r -W %h:%p external.example.com


                  This will allow you to ssh to the internal machine with ssh some_name, use scp, etc.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Oct 16 '17 at 11:01









                  Satō Katsura

                  10.7k11533




                  10.7k11533



























                       

                      draft saved


                      draft discarded















































                       


                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f398370%2fhow-to-copy-files-from-a-double-remote-server-on-a-local-machine%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?

                      Bahrain

                      Postfix configuration issue with fips on centos 7; mailgun relay