惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

D
Darknet – Hacking Tools, Hacker News & Cyber Security
T
Tenable Blog
阮一峰的网络日志
阮一峰的网络日志
S
Schneier on Security
A
Arctic Wolf
Latest news
Latest news
C
Check Point Blog
S
SegmentFault 最新的问题
T
Tor Project blog
B
Blog RSS Feed
The GitHub Blog
The GitHub Blog
爱范儿
爱范儿
腾讯CDC
C
CERT Recently Published Vulnerability Notes
A
About on SuperTechFans
U
Unit 42
L
LINUX DO - 热门话题
罗磊的独立博客
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
MyScale Blog
MyScale Blog
D
Docker
Blog — PlanetScale
Blog — PlanetScale
GbyAI
GbyAI
V
Vulnerabilities – Threatpost
月光博客
月光博客
aimingoo的专栏
aimingoo的专栏
WordPress大学
WordPress大学
Security Latest
Security Latest
博客园_首页
C
Cybersecurity and Infrastructure Security Agency CISA
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
AI
AI
H
Hacker News: Front Page
C
CXSECURITY Database RSS Feed - CXSecurity.com
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Google DeepMind News
Google DeepMind News
T
Tailwind CSS Blog
TaoSecurity Blog
TaoSecurity Blog
博客园 - 司徒正美
云风的 BLOG
云风的 BLOG
S
Securelist
Engineering at Meta
Engineering at Meta
D
DataBreaches.Net
P
Privacy & Cybersecurity Law Blog
T
Threat Research - Cisco Blogs
V2EX - 技术
V2EX - 技术
Vercel News
Vercel News
N
News and Events Feed by Topic
Security Archives - TechRepublic
Security Archives - TechRepublic
S
Secure Thoughts

博客园 - 大袋鼠

Webphser Applcation Server Dmgr无法正常启动 速浪流氓软件删除 2016年&2017年 十年 20140526入职 收到offer 7B 今天收到IBM cat 测试 DN-- distinguished name和DACL SACL的含义(转) 32位服务器是否只能识别4G内存,答案是否 最近在搞TAM TIM 新的环境新的开始 回来踩踩 loadrunner11在win7下安装需注意 Rational Team Concert 3.0安装 Java环境设置、HelloWorld例子、Ant环境及运行(转自MDA之路) 几种常见FTP软件的二进制设置说明 tar: Error exit delayed from previous errors Android联系人全部删除技巧 给Domino系统管理员的十二项建议
linux下scp命令详解
大袋鼠 · 2012-05-24 · via 博客园 - 大袋鼠

scp是 secure copy的缩写, scp是linux系统下基于ssh登陆进行安全的远程文件拷贝命令。linux的scp命令可以在linux服务器之间复制文件和目录.

scp命令的用处:

scp在网络上不同的主机之间复制文件,它使用ssh安全协议传输数据,具有和ssh一样的验证机制,从而安全的远程拷贝文件。

scp命令基本格式:

scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]

[-l limit] [-o ssh_option] [-P port] [-S program]

[[user@]host1:]file1 [...] [[user@]host2:]file2

scp命令的参数说明:

-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)的选项。

scp命令的实际应用

1>从本地服务器复制到远程服务器

(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个指定了文件名

实例:

scp /home/linux/soft/scp.zip root@www.mydomain.com:/home/linux/others/soft

scp /home/linux/soft/scp.zip root@www.mydomain.com:/home/linux/others/soft/scp2.zip

scp /home/linux/soft/scp.zip www.mydomain.com:/home/linux/others/soft

scp /home/linux/soft/scp.zip www.mydomain.com:/home/linux/others/soft/scp2.zip

(2) 复制目录:

命令格式:

scp -r local_folder remote_username@remote_ip:remote_folder

或者

scp -r local_folder remote_ip:remote_folder

第1个指定了用户名,命令执行后需要输入用户密码;

第2个没有指定用户名,命令执行后需要输入用户名和密码;

例子:

scp -r /home/linux/soft/ root@www.mydomain.com:/home/linux/others/

scp -r /home/linux/soft/ www.mydomain.com:/home/linux/others/

上面 命令 将 本地 soft 目录 复制 到 远程 others 目录下,即复制后远程服务器上会有/home/linux/others/soft/ 目录

2>从远程服务器复制到本地服务器

从远程复制到本地的scp命令与上面的命令雷同,只要将从本地复制到远程的命令后面2个参数互换顺序就行了。

例如:

scp root@www.mydomain.com:/home/linux/soft/scp.zip /home/linux/others/scp.zip

scp www.mydomain.com:/home/linux/soft/ -r /home/linux/others/

linux系统下scp命令中很多参数都和 ssh1 有关 , 还需要看到更原汁原味的参数信息,可以运行man scp 看到更细致的英文说明.