Take the 2-minute tour ×

I am on machine A, i can access machine B by ssh and from machine B to C via ssh. But i cannot access machine C directly from A.

The problem is that i have to transfer a folder of size 5 GB to my local machine A from C. I can do this by first transferring them to B and then transferring to A from B. But B has limited disk space. I have a user account on B and C, no root account. But i can do my stuff with the user accounts.

Now please tell me how can i get that folder from C to A? I heard about ssh tunneling here , but it is not clear to me. What should I do?

share|improve this question
add comment

1 Answer

If you have a newer version of scp, you can run scp on host B, with -3 argument.

scp -3 user@hostC:/path/to/file user@hostA:/path/to/file

It routes the traffic through hostB. (See http://www.openbsd.org/cgi-bin/man.cgi?query=scp )

I presume it also gets the login credentials for both servers separately; but, I only have an older version right now, and can't test to be sure.

share|improve this answer
Hi the problem is that host C is a local machine. –  P basak Aug 27 '13 at 3:12
If you can access to hostC from hostB via ssh, as you said in the question, then it shouldn't matter if hostC is on the local subnet or somewhere else. Can you explain why that is a problem? –  Kent Aug 27 '13 at 4:31
I think i was not clear in the question, and i also made a mistake, host A is local, not host C. actually i can access to B from A but not from B to A. –  P basak Aug 27 '13 at 4:52
On hostA, you can set up a tunnel on hostB, which will allow you to connect back to hostA from host B: (on hostA: ssh -R 4567:localhost:22 user@hostB). Then, the scp command would look something like scp -3 user@hostC:/path/to/file -P 4567 user@localhost:/path/to/file (run from hostB, where "localhost:4567" bounces back to hostA). –  Kent Aug 27 '13 at 9:03
add comment

Your Answer


