【SCP命令】安全又快捷的linux小技巧scp命令,2024年最新腾讯架构师深入讲解Linux运维开发

warning: 这篇文章距离上次修改已过190天,其中的内容可能已经有所变动。

SCP (Secure Copy) 是基于SSH(Secure Shell)的一个远程文件拷贝命令,用于在Linux下进行远程文件的拷贝操作。

SCP命令的基本格式如下:




scp [参数] [原路径] [目标路径]

参数说明:

-p:保留原文件的修改时间,访问时间和访问权限。

-r:递归复制整个目录。

-v:详细方式显示输出。 And scp命令会把命令详细执行情况输出,包括读取配置文件,选择和计算密钥,以及其他和文件传送的信息。

-C:使能压缩选项。

-i identity\_file:选择识别文件。

-q:不显示传输进度条。

-P port:注意-p参数需要大写,port是指定数据传输用到的端口号

实例代码:

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



scp local_file remote_username@remote_ip:remote_folder 

或者




scp local_file remote_username@remote_ip:remote_file 

或者




scp local_file remote_ip:remote_folder 

或者




scp local_file remote_ip:remote_file 
  1. 将本地目录复制到远程



scp -r local_folder remote_username@remote_ip:remote_folder
  1. 从远程复制文件到本地



scp remote_username@remote_ip:remote_file local_file

或者




scp -r remote_username@remote_ip:remote_folder local_folder
  1. 使用特定用户身份复制文件



scp -r -l username local_file remote_ip:remote_folder
  1. 使用特定端口复制文件



scp -P port local_file remote_username@remote_ip:remote_file
  1. 使用密钥文件复制文件



scp -i key.pem -P port local_file remote_username@remote_ip:remote_file
  1. 显示复制过程



scp -v local_file remote_username@remote_ip:remote_file
  1. 压缩后复制



scp -C local_file remote_username@remote_ip:remote_file
  1. 后台复制,不阻塞当前会话



scp -n local_file remote_username@remote_ip:remote_file
  1. 从标准输入中读取数据到远程



cat local_file | scp - remote_username@remote_ip:remote_file

注意:在使用scp命令时,需要确保远程服务器已经开启了scp服务,并且本地用户有权限访问远程服务器。如果远程服务器的端口不是默认的22,则需要使用"-P"参数指定端口。

最后修改于:2024年08月16日 11:11

评论已关闭

推荐阅读

DDPG 模型解析,附Pytorch完整代码
2024年11月24日
DQN 模型解析,附Pytorch完整代码
2024年11月24日
AIGC实战——Transformer模型
2024年12月01日
Socket TCP 和 UDP 编程基础(Python)
2024年11月30日
python , tcp , udp
如何使用 ChatGPT 进行学术润色?你需要这些指令
2024年12月01日
AI
最新 Python 调用 OpenAi 详细教程实现问答、图像合成、图像理解、语音合成、语音识别(详细教程)
2024年11月24日
ChatGPT 和 DALL·E 2 配合生成故事绘本
2024年12月01日
omegaconf,一个超强的 Python 库!
2024年11月24日
【视觉AIGC识别】误差特征、人脸伪造检测、其他类型假图检测
2024年12月01日
[超级详细]如何在深度学习训练模型过程中使用 GPU 加速
2024年11月29日
Python 物理引擎pymunk最完整教程
2024年11月27日
MediaPipe 人体姿态与手指关键点检测教程
2024年11月27日
深入了解 Taipy:Python 打造 Web 应用的全面教程
2024年11月26日
基于Transformer的时间序列预测模型
2024年11月25日
Python在金融大数据分析中的AI应用(股价分析、量化交易)实战
2024年11月25日
AIGC Gradio系列学习教程之Components
2024年12月01日
Python3 `asyncio` — 异步 I/O,事件循环和并发工具
2024年11月30日
llama-factory SFT系列教程:大模型在自定义数据集 LoRA 训练与部署
2024年12月01日
Python 多线程和多进程用法
2024年11月24日
Python socket详解,全网最全教程
2024年11月27日