使用 SCP 命令在 Linux/Debian/Ubuntu 终端中进行文件远程传输
SCP(Secure Copy Protocol,安全复制协议)是一种命令行实用程序,允许你通过网络在两个主机之间安全地传输文件。它使用 SSH(Secure Shell,安全外壳协议)进行身份验证和加密,确保传输的数据安全。
SCP 的基本语法
SCP 命令的基本语法如下:
scp [选项] [源文件] [目标位置]
示例
将文件从本地系统复制到远程系统:
scp /path/to/local/file 用户名@远程主机:/path/to/remote/directory
将文件从远程系统复制到本地系统:
scp 用户名@远程主机:/path/to/remote/file /path/to/local/directory
将目录从本地系统复制到远程系统:
scp -r /path/to/local/directory 用户名@远程主机:/path/to/remote/directory
将目录从远程系统复制到本地系统:
scp -r 用户名@远程主机:/path/to/remote/directory /path/to/local/directory