rz&sz&scp端对端文件传输整理

rz&sz&scp端对端文件传输整理

rz sz

rz -E file #从本地计算机上传文件到远程主机

sz -E file #从远程主机下载文件到本地计算机

scp (Secure Copy Protocol)

  • 功能: 通过SSH协议在本地和远程主机之间安全地复制文件
bash 复制代码
scp [选项] [源文件或目录] [目标文件或目录]

选项说明

  • -r: 递归复制整个目录
  • -P port: 指定远程主机的SSH端口(注意:-P是大写)
  • -v: 详细模式,输出调试信息
  • -i identity_file: 指定用于SSH连接的私钥文件
  • -q: 安静模式,不显示进度和错误信息
  • -C: 启用压缩在传输过程中

使用示例

1. 将本地文件复制到远程主机

bash 复制代码
scp localfile.txt user@remotehost:/path/to/destination/
  • 这个命令会将本地的localfile.txt文件复制到远程主机remotehost上的指定目录

2. 将本地目录递归复制到远程主机

bash 复制代码
scp -r localdirectory user@remotehost:/path/to/destination/
  • -r选项表示递归复制localdirectory及其内容到远程主机

3. 从远程主机复制文件到本地

bash 复制代码
scp user@remotehost:/path/to/remote/file.txt /local/path/
  • 这个命令将远程主机上的文件file.txt复制到本地指定的路径

4. 从远程主机递归复制目录到本地

bash 复制代码
scp -r user@remotehost:/path/to/remote/directory /local/path/
  • 这个命令将远程主机上的整个目录复制到本地

5. 指定SSH端口进行文件传输

bash 复制代码
scp -P 2222 localfile.txt user@remotehost:/path/to/destination/
  • 如果远程主机的SSH端口是2222,而不是默认的22,可以使用-P选项指定端口

6. 使用SSH密钥文件进行身份验证

bash 复制代码
scp -i ~/.ssh/id_rsa localfile.txt user@remotehost:/path/to/destination/
  • 如果使用私钥文件进行SSH身份验证,使用-i选项指定密钥文件

7. 同时复制多个文件到远程主机

bash 复制代码
scp file1.txt file2.txt user@remotehost:/path/to/destination/
  • 可以在命令中一次指定多个文件进行复制

8. 从远程主机复制多个文件到本地

bash 复制代码
scp user@remotehost:/path/to/remote/file1.txt user@remotehost:/path/to/remote/file2.txt /local/path/
  • 使用多个源文件进行复制

9. 复制文件并重命名

bash 复制代码
scp localfile.txt user@remotehost:/path/to/destination/newfile.txt
  • 将本地文件复制到远程主机,并在远程主机上重命名为newfile.txt

注意事项

  • 使用scp时,需要确保远程主机的SSH服务已启动,并且有访问权限
  • 在传输大文件时,传输速度可能会受到网络带宽的限制
  • 确保SSH密钥或密码的安全,避免数据泄露
相关推荐
大聪明-PLUS12 分钟前
C++ 中的引用和引用类型
linux·嵌入式·arm·smarc
Vanranrr1 小时前
C++临时对象与悬空指针:一个导致资源加载失败的隐藏陷阱
服务器·c++·算法
苏州知芯传感1 小时前
环境智能的触角:MEMS微振镜赋能分布式光纤传感网络
网络·分布式·3d·mems·激光·微振镜
dualven_in_csdn1 小时前
【疑难问题】某些win11机器 网卡统计也会引起dns client 占用cpu问题
运维·服务器·网络
sanduo1121 小时前
docker 构建编排过程中常见问题
运维·docker·容器
6***v4172 小时前
windows手动配置IP地址与DNS服务器以及netsh端口转发
服务器·windows·tcp/ip
赖small强2 小时前
【Linux驱动开发】ESP-Hosted-FG 深度解析指南
linux·驱动开发·esp32·esp-hosted-fg
翼龙云_cloud2 小时前
亚马逊云渠道商:如何快速开始使用Amazon RDS?
运维·服务器·云计算·aws