-C 允许压缩。(将-C标志传递给ssh,从而打开压缩功能)
-p 保留原文件的修改时间,访问时间和访问权限。 (建议使用,传输时保留属性时间信息,否则会导致时间发生改变无法进行增量传输)
-q 不显示传输进度条。 (很适合crontab任务计划中使用)
-r 递归复制整个目录。
-v 详细方式显示输出。scp和ssh(1)会显示出整个过程的调试信息。这些信息用于调试连接,验证和配置问题。
-c cipher 以cipher将数据传输进行加密,这个选项将直接传递给ssh。
-F ssh_config 指定一个替代的ssh配置文件,此参数直接传递给ssh。
-i identity_file 从指定文件中读取传输时使用的密钥文件,此参数直接传递给ssh。
-l limit 限定用户所能使用的带宽,以Kbit/s为单位。
-o ssh_option 如果习惯于使用ssh_config(5)中的参数传递方式,
-P port 注意是大写的P, port是指定数据传输用到的端口号
-S program 指定加密传输时所使用的程序。此程序必须能够理解ssh(1)的选项。
scp的使用:将本地A主机文件复制到B主机: A:192.168.214.190 B:192.168.214.187
[root@localhost tmp]#scp -p ./files/yum.log 192.168.214.187:/tmp/demo/
The authenticity of host ‘192.168.214.187 (192.168.214.187)’ can’t be established.
RSA key fingerprint is SHA256:BwJdXsDA6F5976fKx1cSxkGJ9/uYYI4zVJ2rd+/Cvj0.
RSA key fingerprint is MD5:85:87:8b:17:d2:79:c7:91:11:46:78:b3:4d:9d:dd:5a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘192.168.214.187’ (RSA) to the list of known hosts.
root@192.168.214.187’s password:
yum.log 100% 0 0.0KB/s 00:00
检查B主机文件:
[root@yufu demo]# ls
f3.log yum.log
[root@yufu demo]# ll
总用量 0
-rw-r–r–. 1 root root 0 3月 31 22:38 f3.log
-rw-------. 1 root root 0 3月 31 22:36 yum.log
将远程主机复制到本地
[root@localhost files]#scp -p 192.168.214.187:/tmp/demo/f3.log /tmp/files/
root@192.168.214.187’s password:
f3.log 100% 0 0.0KB/s 00:00
[root@localhost files]#ls
f3.log ff.txt yum.log
复制目录
[root@localhost tmp]#scp -rp ./files/ 192.168.214.187:/tmp/demo
root@192.168.214.187’s password:
f3.log 100% 0 0.0KB/s 00:00
yum.log 100% 0 0.0KB/s 00:00
ff.txt 100% 5 7.3KB/s 00:00
[root@localhost tmp]#
检查远程主机目录
[root@yufu demo]# tree
.
└── files
├── app
├── f3.log
├── ff.txt
└── yum.log
2 directories, 3 files
- rz sz (lrzsz)
rz sz指令可以实现linux和windows之间的文件传输,但要求在windows客户端要安装Xshell或SecureCRT远程连接工具。
rz指令和sz指令是一对上传与下载的指令。它们的软件包名为lrzsz。
rz sz指令使用很简单,执行rz 指令,远程连接工具会弹出windows文件选择窗口,只要选择要上传的文件即可
工具的安装:
$ yum install lrzsz -y
文件上传: