scp是个好工具,咋用呢?

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/mantis_1984/article/details/80451989
    最近调试个小程序,交叉编译需要将编译后的可执行程序下载到target,之前一直搭建的rsync服务下载,或者使用ftp下载,又或者用mount的 方式,但是这几个方式都比较庞大,要用专用软件或者配置繁琐,就在想有没有简单点的,linux系统之间传文件的工具,网上一搜还真有,scp 就是这样一个便捷的工具,网上关于scp的使用总结一堆,但是我还是想自己总结下,实践出真知。
man scp 看一下先
shell窗口敲man scp可以看到,SCP——secure copy(remote file copy program)是远程文件的安全拷贝程序。
scp copies files between hosts on a network.  It uses ssh(1) for data transfer, and uses the same  authentication and provides the same security as ssh(1).  scp will ask for passwords or passphrases if  they are needed for authentication.(scp在网络上复制主机间的文件。它使用SSH1进行数据传输,并且使用相同的身份验证,并提供与SSH1相同的安全。)
File names may contain a user and host specification to indicate that the file is to be copied to/from  that host.  Local file names can be made explicit using absolute or relative pathnames to avoid scp  treating file names containing ‘:’ as host specifiers.  Copies between two remote hosts are also permit ted.(文件名可能包含用户和主机规范,以指示要将文件拷贝到远端主机,或者从远端主机下载。本地文件名可以使用绝对路劲名或相对路径名显式显示,以避免scp将包含“:”的文件名作为主机制定程序处理。两个远程主机之间的拷贝也是允许的。)
以上摘取自manual,更多用法就不写了,自己看吧,不懂英文查字典~~

举几个常用例子
1、从远端下载文件到本机指定目录:
用法:scp  username@remote_host:/remote_path/remote_file   /local_path/

举例:scp [email protected]:/home/admin/Image ~/scp_test


2、从远端下载文件夹到本机制定目录:

用法:scp  -r username@remote_host:/remote_path   /local_path/  (增加-r属性)

举例:scp  -r [email protected]:/home/admin/test/ ~/scp_test/


3、从本地上传文件到远端目录:

用法:scp file.a  remote_user@remost_host:/remote_path/

举例:scp a_loc_file [email protected]:/home/admin



4、从本地上传文件夹到远端目录:
用法:scp -r  file_path/  remote_user@remost_host:/remote_path/

举例:scp -r audmixer [email protected]:/home/admin


操作基本都需要输入远端的密码哦~,还有一些命令选项请 man scp,就写这么多吧,那我现在走吧,拜拜。

猜你喜欢

转载自blog.csdn.net/mantis_1984/article/details/80451989