当前位置:网站首页>一文详解scp命令
一文详解scp命令
2022-07-19 10:47:00 【全栈程序员站长】
大家好,又见面了,我是全栈君。
scp
加密的方式在本地主机和远程主机之间复制文件
补充说明
scp命令 用于在Linux下进行远程拷贝文件的命令,和它类似的命令有cp,不过cp只是在本机进行拷贝不能跨服务器,而且scp传输是加密的。可能会稍微影响一下速度。当你服务器硬盘变为只读read only system时,用scp可以帮你把文件移出来。另外,scp还非常不占资源,不会提高多少系统负荷,在这一点上,rsync就远远不及它了。虽然 rsync比scp会快一点,但当小文件众多的情况下,rsync会导致硬盘I/O非常高,而scp基本不影响系统正常使用。
语法
scp(选项)(参数)
选项
-1:使用ssh协议版本1;
-2:使用ssh协议版本2;
-4:使用ipv4;
-6:使用ipv6;
-B:以批处理模式运行;
-C:使用压缩;
-F:指定ssh配置文件;
-i:identity_file 从指定文件中读取传输时使用的密钥文件(例如亚马逊云pem),此参数直接传递给ssh;
-l:指定宽带限制;
-o:指定使用的ssh选项;
-P:指定远程主机的端口号;
-p:保留文件的最后修改时间,最后访问时间和权限模式;
-q:不显示复制进度;
-r:以递归方式复制。
参数
- 源文件:指定要复制的源文件。
- 目标文件:目标文件。格式为
[email protected]:filename
(文件名为目标文件的名称)。
实例
从远程复制到本地的scp命令与上面的命令雷同,只要将从本地复制到远程的命令后面2个参数互换顺序就行了。
从远程机器复制文件到本地目录
scp [email protected]:/opt/soft/nginx-0.5.38.tar.gz /opt/soft/
从10.10.10.10机器上的/opt/soft/
的目录中下载nginx-0.5.38.tar.gz 文件到本地/opt/soft/
目录中。
从亚马逊云复制OpenV**到本地目录
scp -i amazon.pem [email protected]:/usr/local/openvpn_as/etc/exe/openvpn-connect-2.1.3.110.dmg openvpn-connect-2.1.3.110.dmg
从10.10.10.10机器上下载openvpn安装文件到本地当前目录来。
从远程机器复制到本地
scp -r [email protected]:/opt/soft/mongodb /opt/soft/
从10.10.10.10机器上的/opt/soft/
中下载mongodb目录到本地的/opt/soft/
目录来。
上传本地文件到远程机器指定目录
scp /opt/soft/nginx-0.5.38.tar.gz [email protected]:/opt/soft/scptest
# 指定端口 2222
scp -rp -P 2222 /opt/soft/nginx-0.5.38.tar.gz [email protected]:/opt/soft/scptest
复制本地/opt/soft/
目录下的文件nginx-0.5.38.tar.gz到远程机器10.10.10.10的opt/soft/scptest
目录。
上传本地目录到远程机器指定目录
scp -r /opt/soft/mongodb [email protected]:/opt/soft/scptest
上传本地目录/opt/soft/mongodb
到远程机器10.10.10.10上/opt/soft/scptest
的目录中去。
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/111537.html原文链接:https://javaforall.cn
边栏推荐
- 实验3 MGRE 综合实验
- What is the difference between SSL and TLS
- "Wheels" to improve development efficiency
- win系统开机增加启动软件项
- Android面试Hash原理详解二
- 【FAQ】接入HMS Core推送服务,服务端下发消息常见错误码原因分析及解决方法
- [cann training camp] brief introduction the format of general target recognition data after decoding is customized from yuv420sp nv12 to yuv420sp nv21
- 实验4 MGRE环境下的OSPF实验
- 华泰证券账户开通流程,手机上开户安全吗
- 网络跟不上、软件不好使……“云面试”机会很多尴尬不少
猜你喜欢
How to prevent repeated payment of orders?
Experiment 4 OSPF experiment in mGRE environment
Blood spitting finishing nanny level series tutorial - playing Fiddler bag capturing tutorial (7) - Fiddler status panel -quickexec command line
一文让你学会使用flowable工作流
趣店罗敏:从寒门贵子到面临退市 再到抢占预制菜新风口
IPhone 14 Max production progress lags behind: or affect the delivery ratio of the first batch of products
8、ORM简介与gorm入门
Talk about what's going on with C # backstage GC?
系统App 签名JKS制作及静默安装
Detailed explanation of Android interview hash principle II
随机推荐
OSPF of hcip
扎心了!16岁女生被骗3万后不服气又被骗5万
OSPF optimization - summary and special areas
Summer vacation daily question week 6:7.11 - 7.17
如何使用 SAP Intelligent Robotic Process Automation 自动操作 Excel
Intel base instruction -- bnd
鉴源论坛 · 观模丨测试的充分性问题
OSPF-LSA
Dotnet reading WPF source code notes how to trigger rendering collection
gdb 定位strip后程序的main地址
一次装修合同引发的思考
How to prevent repeated payment of orders?
2021 年6月面试遭遇滑铁卢,现在这么内卷了吗
[depth] the new LAAS agreement elephant: the key to revitalizing the development of the defi track
【Latex】PPT画图,导出emf格式,word插入emf文件并导出pdf,pdf裁剪并导出eps文件,latex插入eps文件
非金融类去中心化应用的产品原则
System app signature JKS production and silent installation
人均瑞数系列,瑞数 4 代 JS 逆向分析
Too busy or too lazy? The same fund manager has the same view in the quarterly reports of different products
vivo官网APP全机型UI适配方案