1.什么是scp
使用 man scp查看文档描述如下
scp copies files between hosts on a network. It uses ssh(1) for data transfer, and uses the same authentication and provides the same security as ssh(1). Unlike rcp(1), scp will ask for passwords or passphrases if they are needed for authentication.
File names may contain a user and host specification to indicate that the file is to be copied to/from that host. Local file names can be made explicit using absolute or relative pathnames to avoid scp treating file names containing ‘:’ as host specifiers. Copies between two remote hosts are also per‐mitted.
2.使用方式
scp option file_source file_target
3.从本地复制文件到远程主机
$ scp failname remote_user_name@remote_url:filename
4.从远程复制文件到本地
$ scp remote_user_name@remote_url:filename failname
5.两个远程主机复制
# 有些主机可能不支持此种方式
$ scp remote1_user_name@remote1_url:filename remote2_user_name@remote2_url:filename
6.常用选项
-B: 使用批处理模式(传输过程中不询问传输口令或短语)
-C: 允许压缩。(将-C标志传递给ssh,从而打开压缩功能)
-p:保留原文件的修改时间,访问时间和访问权限。
-r: 递归复制整个目录。
-v:详细方式显示输出。scp和ssh(1)会显示出整个过程的调试信息。这些信息用于调试连接,验证和配置问题。
-F ssh_config: 指定一个替代的ssh配置文件,此参数直接传递给ssh。
-P port:注意是大写的P, port是指定数据传输用到的端口号