1

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.

jvatic
  • 111
  • 5

1 Answers1

4

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.

Andrew M.
  • 11,182
  • 2
  • 35
  • 29