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密钥或密码的安全,避免数据泄露
相关推荐
qq_5895681016 小时前
centos6.8镜像源yum install不成功,无法通过镜像源下载的解决方式
linux·运维·centos
weixin_5160230717 小时前
linux下fcitx5拼音的安装
linux·运维·服务器
hunter145017 小时前
Linux 进程与计划任务
linux·运维·服务器
上海云盾安全满满17 小时前
高防IP线路质量重要吗
网络·网络协议·tcp/ip
楼田莉子17 小时前
Linux学习之磁盘与Ext系列文件
linux·运维·服务器·c语言·学习
陌上花开缓缓归以17 小时前
linux 怎么模拟系统panic重启
linux·运维·服务器
KL's pig/猪头/爱心/猪头18 小时前
写一个rv1106的led驱动3-功能函数编写
linux·驱动开发·rv1106
hoududubaba18 小时前
ORAN共享小区的基本概念
网络·网络协议
月白风清江有声18 小时前
vscode使用git
linux·运维·服务器
山峰哥18 小时前
数据库工程核心:SQL调优让查询效率飙升的实战密码
网络·汇编·数据库·sql·编辑器