Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|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. –  jvatic Jan 3 '11 at 20:08
add comment

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.

share|improve this answer
    
Thanks, this works great combined with launchd –  jvatic Jan 3 '11 at 20:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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