Crawlicious

tools for web business

multi hop scp ssh scp file copy

| 0 comments

How can you copy a file from host1 through host2, and end up on host3? Here is my quick hack solution for a scp / ssh copy.

cat file.txt | ssh -A user1@host2 ‘cat | ssh -A user@host3 “cat > file.txt”‘

or, you can just set up a tunnel from host1 to host3 like this

ssh -L 9999:host3:22 host2

this will open up the local port 9999 which gets tunnelled through host2 and ends up at host3. Now you can do commands like this.

scp -P 9999 file.txt user2@localhost:file.txt

and there you have it!

Leave a Reply