当前位置:网站首页>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
- Informatics Olympiad 1955: [11noip popularization group] Swiss round | openjudge 4.1 4363: Swiss round | Luogu p1309 [noip2011 popularization group] Swiss round
- Innovation training (IV) preliminary preparation - server
- js 判斷數字字符串中是否含有字符
- Com alibaba. Common methods of fastjson
- Painless upgrade of pixel series
- Innovation training (II) task division
- Leetcode 1547: minimum cost of cutting sticks
- Unity RawImage背景无缝连接移动
- Solve valueerror: argument must be a deny tensor: 0 - got shape [198602], but wanted [198602, 16]
猜你喜欢
【数据库】MySQL基本操作(基操~)
Painless upgrade of pixel series
Thoughts on a small program
深度学习笔记 —— 语义分割和数据集
[2022 ICLR] Pyraformer: Low-Complexity Pyramidal Attention for Long-Range 时空序列建模和预测
DIY is an excel version of subnet calculator
[2021] Spatio-Temporal Graph Contrastive Learning
What are the redis data types
Repair of self calibration SPC failure of Tektronix oscilloscope dpo3054
[database] MySQL basic operation (basic operation ~)
随机推荐
Unity摄像头跟随鼠标旋转
[2022 ICLR] Pyraformer: Low-Complexity Pyramidal Attention for Long-Range 时空序列建模和预测
深度学习笔记 —— 语义分割和数据集
selenium模式下切换窗口,抓取数据的实现
Agile practice | agile indicators to improve group predictability
POI export message list (including pictures)
【数据库】MySQL单表查询
深度学习笔记 —— 微调
Custom switch control
The programmer starts the required application with one click of window bat
Simply drag objects to the item bar
跨境电商 | Facebook 和 Instagram:哪个社交媒体更适合你?
Leetcode009 -- search the target value in the array with binary search
Knowledge points sorting: ES6
Learning Android from scratch -- Introduction
vscode ipynb文件没有代码高亮和代码补全解决方法
Learning Android II from scratch - activity
Sword finger offer: the path with a certain value in the binary tree (backtracking)
Flink case - Kafka, MySQL source
Open the past and let's start over.