I need a way of copying a file through nested servers, as in

localhost$ ssh user@host1
host1$ ssh host2

where host2 is on an off-site intranet and not directly accessible.

Is there a way of using scp to copy a file to localhost from host2 through host1 in a single command? Or am I stuck first copying the file to host1 first?

Thanks in advance.

link|improve this question
possible duplicate of How do I do Multihop SCP transfers? – Zoredache Jan 3 '11 at 7:02
Yes, didn't see that. – Jesse Stuart Jan 3 '11 at 20:08
feedback

1 Answer

What you're really looking for is a way to tunnel SSH connections. I.e.,

ssh -f host1 -L 16384:host2:22 -N

This will setup a tunnel on host1 that tunnels host1:16384 to host2:22. So when you run ssh host1:16384, you'll actually connect to host2. See the link for more in depth information and a nifty howto.

link|improve this answer
Thanks, this works great combined with launchd – Jesse Stuart Jan 3 '11 at 20:05
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.