天天看点

scp命令详解

基础命令学习目录

1、从服务器上下载文件

scp username@servername:/path/filename /var/www/local_dir(本地目录)

 例如scp [email protected]:/var/www/test.txt  把192.168.0.101上的/var/www/test.txt 的文件下载到/var/www/local_dir(本地目录)

2、上传本地文件到服务器

scp /path/filename username@servername:/path  

例如scp /var/www/test.php  [email protected]:/var/www/  把本机/var/www/目录下的test.php文件上传到192.168.0.101这台服务器上的/var/www/目录中

3、从服务器下载整个目录

scp -r username@servername:/var/www/remote_dir/(远程目录) /var/www/local_dir(本地目录)

例如:scp -r [email protected]:/var/www/test  /var/www/ 

4、上传目录到服务器

scp  -r local_dir username@servername:remote_dir

例如:scp -r test  [email protected]:/var/www/   把当前目录下的test目录上传到服务器的/var/www/ 目录

---------------------

作者:LoganMaaa

来源:CSDN

原文:https://blog.csdn.net/qq_34516081/article/details/81237594

版权声明:本文为博主原创文章,转载请附上博文链接!

scp是secure copy的简写,用于在Linux下进行远程拷贝文件的命令, scp传输是加密的,可能会稍微影响一下速度。另外,scp还非常不占资源,不会提高多少系统负荷,在这一点上,rsync就远远不及它了。虽然 rsync比scp会快一点,但当小文件众多的情况下,rsync会导致硬盘I/O非常高,而scp基本不影响系统正常使用

常见命令参数

1

2

3

4

5

6

7

8

9

10

usage:

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

-q:  quiet

-r:   recuersive

-p:   properity

-

v

:   verbose

-i:   identity_file      【从指定文件中读取传输时使用的密钥文件,此参数直接传递给

ssh

-P:  port

常见命令展示

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个没有指定用户名,命令执行后需要输入用户名和密码

作者:小a玖拾柒

出处:http://www.cnblogs.com/ftl1012/

-------------------------------------------

个性签名: 所有的事情到最後都是好的,如果不好,那說明事情還沒有到最後~

本文版权归作者【小a玖拾柒】和【博客园】共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利!