当前位置:网站首页>scp命令详解
scp命令详解
2022-04-23 04:54:00 【黄佳俊、】
先说下常用的情况:
两台机器IP分别为:A.104.238.161.75,B.43.224.34.73。
在A服务器上操作,将B服务器上/home/lk/目录下所有的文件全部复制到本地的/root目录下,命令为:scp -r [email protected]:/home/lk /root。
在A服务器上将/root/lk目录下所有的文件传输到B的/home/lk/cpfile目录下,命令为:scp -r /root/lk [email protected]:/home/lk/cpfile。
scp在跨机器复制的时候为了提高数据的安全性,使用了ssh连接和加密方式,如果机器之间配置了ssh免密码登录,那在使用scp的时候密码都不用输入。
命令详解:
scp是secure copy的简写,用于在Linux下进行远程拷贝文件的命令,和它类似的命令有cp,不过cp只是在本机进行拷贝不能跨服务器,而且scp传输是加密的。可能会稍微影响一下速度。当你服务器硬盘变为只读 read only system时,用scp可以帮你把文件移出来。另外,scp还非常不占资源,不会提高多少系统负荷,在这一点上,rsync就远远不及它了。虽然 rsync比scp会快一点,但当小文件众多的情况下,rsync会导致硬盘I/O非常高,而scp基本不影响系统正常使用。
1.命令格式:
scp [参数] [原路径] [目标路径]
2.命令功能:
scp是 secure copy的缩写, scp是linux系统下基于ssh登陆进行安全的远程文件拷贝命令。linux的scp命令可以在linux服务器之间复制文件和目录。
3.命令参数:
-1 强制scp命令使用协议ssh1
-2 强制scp命令使用协议ssh2
-4 强制scp命令只使用IPv4寻址
-6 强制scp命令只使用IPv6寻址
-B 使用批处理模式(传输过程中不询问传输口令或短语)
-C 允许压缩。(将-C标志传递给ssh,从而打开压缩功能)
-p 保留原文件的修改时间,访问时间和访问权限。
-q 不显示传输进度条。
-r 递归复制整个目录。
-v 详细方式显示输出。scp和ssh(1)会显示出整个过程的调试信息。这些信息用于调试连接,验证和配置问题。
-c cipher 以cipher将数据传输进行加密,这个选项将直接传递给ssh。
-F ssh_config 指定一个替代的ssh配置文件,此参数直接传递给ssh。
-i identity_file 从指定文件中读取传输时使用的密钥文件,此参数直接传递给ssh。
-l limit 限定用户所能使用的带宽,以Kbit/s为单位。
-o ssh_option 如果习惯于使用ssh_config(5)中的参数传递方式,
-P port 注意是大写的P, port是指定数据传输用到的端口号
-S program 指定加密传输时所使用的程序。此程序必须能够理解ssh(1)的选项。
4.使用实例:
scp命令的实际应用概述:
从本地服务器复制到远程服务器:
(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,2个指定了用户名,命令执行后需要输入用户密码,第1个仅指定了远程的目录,文件名字不变,第2个指定了文件名
第3,4个没有指定用户名,命令执行后需要输入用户名和密码,第3个仅指定了远程的目录,文件名字不变,第4个指定了文件名
(2) 复制目录:
命令格式:
scp -r local_folder remote_username@remote_ip:remote_folder
或者
scp -r local_folder remote_ip:remote_folder
第1个指定了用户名,命令执行后需要输入用户密码;
第2个没有指定用户名,命令执行后需要输入用户名和密码;
版权声明
本文为[黄佳俊、]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_48419914/article/details/124315676
边栏推荐
- Leetcode002 -- inverts the numeric portion of a signed integer
- Spark optimization
- Perfect test of coil in wireless charging system with LCR meter
- Differences between redis and MySQL
- What's the difference between error and exception
- 信息学奥赛一本通 1212:LETTERS | OpenJudge 2.5 156:LETTERS
- L2-011 play binary tree (build tree + BFS)
- 用LCR表完美测试无线充电系统中的线圈
- Windows remote connection to redis
- Record the ThreadPoolExecutor main thread waiting for sub threads
猜你喜欢
[database] MySQL multi table query (I)
Record the ThreadPoolExecutor main thread waiting for sub threads
Spark FAQ sorting - must see before interview
Details related to fingerprint payment
跨境电商 | Facebook 和 Instagram:哪个社交媒体更适合你?
C language: Advanced pointer
[database] MySQL single table query
redis数据类型有哪些
Introduction to raspberry pie 3B - system installation
Perfect test of coil in wireless charging system with LCR meter
随机推荐
Excel uses the functions of replacement, sorting and filling to comprehensively sort out financial data
Sword finger offer: the path with a certain value in the binary tree (backtracking)
Raspberry pie + opencv + opencv -- face detection ------- environment construction
Open the past and let's start over.
Graduation project
[WinUI3]编写一个仿Explorer文件管理器
[database] MySQL basic operation (basic operation ~)
Analysis of POM files
Set Chrome browser background to eye protection (eye escort / darkreader plug-in)
使用model.load_state_dict()时,出现AttributeError: ‘str‘ object has no attribute ‘copy‘
ApplicationContext injection bean
vscode ipynb文件没有代码高亮和代码补全解决方法
Simply drag objects to the item bar
Spark case - wordcount
信息学奥赛一本通 1955:【11NOIP普及组】瑞士轮 | OpenJudge 4.1 4363:瑞士轮 | 洛谷 P1309 [NOIP2011 普及组] 瑞士轮
js 判断数字字符串中是否含有字符
Unity摄像头跟随鼠标旋转
Leetcode005 -- delete duplicate elements in the array in place
Flink's important basics
leetcode——启发式搜索