scp文件拷贝简易使用

scp远程复制

属性变化

需要复制所属关系需要用-p选项

  • 源目录复制之后目的目录的属性:

srcdrwxr-xr-x. 2 root root 6 9月 4 16:28 2.txt

dstdrwxr-xr-x. 2 root root 6 9月 4 16:30 2.txt

  • 源文件复制之后:

src-rw-r--r--. 1 root root 0 9月 4 16:36 4

dst-rw-r--r--. 1 root root 0 9月 4 16:37 4

  • 源文件改过权限复制之后:

src-rwxrwxr--. 1 root root 0 9月 4 16:33 3

dst-rwxr-xr--. 1 root root 0 9月 4 16:34 3

src-rw-r--r-x. 1 root root 0 9月 4 16:44 6

dst-rw-r--r-x. 1 root root 0 9月 4 16:44 6

src-rwxr-xr-x. 1 root root 0 9月 4 16:45 7

dst-rwxr-xr-x. 1 root root 0 9月 4 16:46 7

  • 源文件的所属用户在目的主机上没有:

src-rw-r--r--. 1 jbc root 0 9月 4 16:06 1.txt

dst-rw-r--r--. 1 root root 0 9月 4 16:21 1.txt

  • 源文件所属组在目的主机没有:

src-rw-r--r--. 1 root jbc 0 9月 4 16:42 5

dst-rw-r--r--. 1 root root 0 9月 4 16:42 5

  • 源文件改过权限及所属用户,对方主机无该用户

src-rwxr-xr-x. 1 jbc root 0 10月 12 10:36 8

dst-rwxr-xr-x. 1 root root 0 10月 12 10:37 8

  • 改所属用户,对方存在该用户

src-rw-r--r--. 1 jbc root 0 10月 12 10:39 9

dst-rw-r--r--. 1 root root 0 10月 12 10:39 9

  • umask不一样复制时什么结果?

权限可以复制,因此无影响

操作参数

文件scp root@10.112.98.132:/root/temp/1.txt root@10.112.98.134:/root/temp/1.txt

目录scp -r root@10.112.98.132:/root/temp/2.txt root@10.112.98.134:/root/temp/2.txt

文件已存在则会直接覆盖

原文地址:https://www.cnblogs.com/boxker/p/11660286.html