Linux – How to transfer entire directory from one server to another via SSH

linuxssh

I have two servers, access to SSH on both. I want to transfer entire directory from server A to server B.
They are both remote servers to me.

Am I right to assume it is possible to log into SSH terminal on my local PC, connect to server A, and do some magical command that will initiate a transfer between the two servers while being able to log out of terminal on my own local machine?

Best Answer

On server A:

$ scp -r /path/to/directory someuser@serverB:/path/to/files/.

The above command will copy the files from serverA to serverB using someuser (a user on serverB). The directory (/path/to/directory) will be copied as a directory to the directory on serverB into the directory /path/to/files/.

Related Question