小编给大家分享一下linux中的scp命令怎么用,希望大家阅读完这篇文章之后都有所收获,下面让我们一起去探讨吧!
scp是secure copy的简写, 是 linux 系统下基于 ssh 登陆进行安全的远程文件拷贝命令。scp 是加密的,rcp 是不加密的,scp 是 rcp 的加强版。
scp source target
[student@servera ~]scp log.tar root@serverb:/logbackup
The authenticity of host 'serverb (172.25.250.11)' can't be established.
ECDSA key fingerprint is SHA256:BCd8VCfEpGbUo3zb1De0hd1Q5nOMEzYNpMFu5o7j4Fg.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'serverb,172.25.250.11' (ECDSA) to the list of known hosts.
root@serverb's password:
log.tar 100% 11MB 20.8MB/s 00:00
[student@servera ~] ssh root@serverb "ls /logbackup"root@serverb's password:
log.tar
[student@servera ~]scp root@serverb:/logbackup/log.tar backup/
root@serverb's password:
log.tar 100% 11MB 25.5MB/s 00:00
[student@servera ~] ls backup/
log.tar
如果是目录,我们可以通过 -r 选项进行递归的方式,复制整个目录内容
[student@servera ~]$ scp -r root@serverb:/var/log/ backup/
root@serverb's password:
lastlog 100% 285KB 5.9MB/s 00:00
README 100% 1040 260.8KB/s 00:00
wtmp 100% 6912 2.6MB/s 00:00
btmp 100% 0 0.0KB/s 00:00
audit.log 100% 208KB 8.0MB/s 00:00
sssd.log 100% 0 0.0KB/s 00:00
sssd_implicit_files.log 100% 109 32.9KB/s 00:00
sssd_nss.log 100% 94 8.6KB/s 00:00
rhsm.log 100% 3642 1.0MB/s 00:00
tuned.log 100% 2434 904.9KB/s 00:00
messages 100% 1459KB 18.1MB/s 00:00
secure 100% 8298 3.4MB/s 00:00
maillog 100% 0 0.0KB/s 00:00
spooler 100% 0 0.0KB/s 00:00
dnf.log 100% 107KB 3.4MB/s 00:00
dnf.librepo.log 100% 245KB 8.4MB/s 00:00
dnf.rpm.log 100% 21KB 2.3MB/s 00:00
hawkey.log 100% 18KB 3.8MB/s 00:00
cron 100% 7166 706.4KB/s 00:00
boot.log 100% 0 0.0KB/s 00:00
我们还可以使用 scp 把一个文件从远端的一台主机,复制到另外一台主机上
[student@workstation ~]scp student@servera:/home/student/log.tar student@serverb:/home/student/
student@serverb's password:
log.tar 100% 670KB 19.6MB/s 00:00
Connection to servera closed.
[student@workstation ~] ssh student@serverb "ls -l"
total 672
-rw-rw-r--. 1 student student 686080 Nov 6 20:54 log.tar
看完了这篇文章,相信你对“linux中的scp命令怎么用”有了一定的了解,如果想了解更多相关知识,欢迎关注亿速云行业资讯频道,感谢各位的阅读!
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。