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密钥或密码的安全,避免数据泄露
相关推荐
chenbin52014 分钟前
Jenkins 自动构建Job
运维·jenkins
java 凯15 分钟前
Jenkins插件管理切换国内源地址
运维·jenkins
AI服务老曹19 分钟前
运用先进的智能算法和优化模型,进行科学合理调度的智慧园区开源了
运维·人工智能·安全·开源·音视频
shimly1234561 小时前
tcpdump 用法示例
网络·测试工具·tcpdump
风静如云1 小时前
OpenBMC:BmcWeb定义service
linux
sszdzq2 小时前
Docker
运维·docker·容器
book01212 小时前
MySql数据库运维学习笔记
运维·数据库·mysql
leoufung2 小时前
VIM FZF 安裝和使用
linux·编辑器·vim
bugtraq20213 小时前
XiaoMi Mi5(gemini) 刷入Ubuntu Touch 16.04——安卓手机刷入Linux
linux·运维·ubuntu
xmweisi3 小时前
【华为】报文统计的技术NetStream
运维·服务器·网络·华为认证