scp
(secure copy)是Linux系统下用于在本地与远程主机之间安全地复制文件的命令。它基于SSH协议进行数据传输,因此传输过程是加密的,确保了文件传输的安全性。
scp [选项] [源文件] [目标文件]
-r
:递归复制整个目录。-P
:指定SSH端口(默认是22)。-i
:指定私钥文件进行身份验证。-v
:显示详细信息(用于调试)。-C
:启用压缩。-F
:指定替代的SSH配置文件。scp /path/to/local/file username@remote_host:/path/to/remote/directory
scp username@remote_host:/path/to/remote/file /path/to/local/directory
scp -r /path/to/local/directory username@remote_host:/path/to/remote/directory
scp -P 2222 -i ~/.ssh/id_rsa /path/to/local/file username@remote_host:/path/to/remote/directory
600
)。总之,scp
是一个强大而灵活的工具,用于在Linux系统之间安全地传输文件。通过掌握其基本用法和选项,你可以轻松地在不同主机之间同步和管理文件。
领取专属 10元无门槛券
手把手带您无忧上云