Posts Tagged: copy

We need to scp a file between two hosts. The problem is that the two hosts (A & C) cannot directly communicate. We can solve this using a SSH tunnel and an intermediate host (B) that can communicate with both. This also means, the command for Host B needs to run first, then the scp command for host A.:

Host A (source)

This will scp to localhost on port 3000 which is actually our tunnel to host c — /destination_file is the path on host C

Shell

1

scp-P3000/source/fileusername@localhost:/destination_file

Host B (intermediate)

Shell

1

ssh-R3000:ip.of.host.a:22ip.of.host.c

Host C (destination)

Also, if you have spaces in the paths make sure to escape the space with \ e.g.

I need to clone all the files and folders (with a couple of exceptions) in this directory into the /public_html/dev folder. We need to exclude the dev/ folder as it is the destination, and also want to exclude the dev2/ folder.