当前位置:网站首页>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
边栏推荐
- Wine (COM) - basic concept
- Windows remote connection to redis
- POI export message list (including pictures)
- Spell it! Two A-level universities and six B-level universities have abolished master's degree programs in software engineering!
- Progress of innovation training (III)
- The programmer starts the required application with one click of window bat
- What are the redis data types
- Pixel 5 5g unlocking tutorial (including unlocking BL, installing edxposed and root)
- Gets all dates between two times
- Innovation training (V) mid term inspection
猜你喜欢

Perfect test of coil in wireless charging system with LCR meter

Record the ThreadPoolExecutor main thread waiting for sub threads

Learning Android from scratch -- Introduction
![[database] MySQL multi table query (I)](/img/c7/43167aa6169c24a8d9734032775335.png)
[database] MySQL multi table query (I)
![[2021] Spatio-Temporal Graph Contrastive Learning](/img/7d/67a0bfa0adecee24bbe291a25ae906.png)
[2021] Spatio-Temporal Graph Contrastive Learning
![View, modify and delete [database] table](/img/a2/fcb38f2006772a1ec45cab520620ba.png)
View, modify and delete [database] table

【数据库】MySQL基本操作(基操~)

Detailed explanation of the differences between TCP and UDP

简单的拖拽物体到物品栏

Unity RawImage背景无缝连接移动
随机推荐
Sword finger offer: the path with a certain value in the binary tree (backtracking)
Solve valueerror: argument must be a deny tensor: 0 - got shape [198602], but wanted [198602, 16]
Set Chrome browser background to eye protection (eye escort / darkreader plug-in)
js 判斷數字字符串中是否含有字符
How can continuous integration (CI) / continuous delivery (CD) revolutionize automated testing
Innovation training (V) configuration information
QPushbutton 槽函数被多次触发
Graduation project
拼了!两所A级大学,六所B级大学,纷纷撤销软件工程硕士点!
跨境电商 | Facebook 和 Instagram:哪个社交媒体更适合你?
C language: Advanced pointer
JS determines whether the numeric string contains characters
Spark optimization
Unity camera rotation with sliding effect (rotation)
深度学习笔记 —— 语义分割和数据集
Learning Android V from scratch - UI
Excel protects worksheets and workbooks from damage
【数据库】MySQL多表查询(一)
PHP 统计指定文件夹下文件的数量
Innovation training (IX) integration