The SCP command can copy a file of the local machine to a specified remote directory, or recursively copy a directory of the local machine to a specified remote directory.
Remote recursive replication is very important. For example, for a hadoop cluster, after the configuration is completed on one machine, the entire directory needs to be copied to each remote node
scp -r localdir hadoop@localhost:/home/hadoop/learninglinux/ddd
The above command recursively copies the localdir of the local machine to the ddd directory under the remote machine, and the result is that a localdir is generated in the ddd directory
If the -r option is not specified, copying a directory is not allowed, and the following error is reported:
localdir: not a regular file
By default, scp performs remote replication by overwriting, that is, if the remote already has a file with the same name, the file will be overwritten.