SCP remote-to-remote copying

Using scp (secure copy, over ssh) for remote-to-remove copying has a bit unexpected behaviour for me. The expectation was, that copied data are transfered through machine where scp command runs. But this is not the default behaviour of scp.

Default copy scenario between two remote hosts makes a direct connection from source server to the destination server. That sounds quite reasonable, except cases when servers cannot see each other.

$ scp src\_server:/some\_dir/* dest\_server:/some\_another_dir

Solution is to use -3 parameter, which forces copy data over local machine. For more options see scp manual page.

$ scp -3 src\_server:/some\_dir/* dest\_server:/some\_another_dir

#linux #cli