An SSH tunnel via multiple hops | ssh -D9999 username@example.com | ssh -L 9999:host2:1234 -N host1
# First, open the tunnel
ssh -L 1234:remote2:22 -p 45678 user1@remote1
# Then, use the tunnel to copy the file directly from remote2
scp -P 1234 user2@localhost:file .
Note that you connect as
user2@localhost
in the actual scp
command, because it is on port 1234 on localhost that the first ssh
instance is listening to forward connections to remote2
. Note also that you don't need to run the first command for every subsequent file copy; you can simply leave it running.
Comments
Post a Comment