使用openssh-clients的scp命令来传输文件
系統環境:RedHat Enterprise Linux Server 6
主機desktop作為客戶端,服務器為9.9.9.9(域名為www.huage.com)
以下4個實例均在客戶端完成,此時并未通過ssh登錄到www.huage.com
1、復制遠程服務器的文件到本地:
[root@desktop huage]#scp -P 22 root@9.9.9.9:/etc/yum.conf /home/huage/tmp/
將遠程服務器上的/etc/yum.conf文件拷貝到本機的/home/huage/tmp/目錄
2、復制遠程服務器的目錄到本地:
[root@desktop huage]#scp -vrp -P 22 root@9.9.9.9:/sony/home/huage/
將遠程服務器上的目錄/sony/拷貝到本機的/home/huage/目錄
3、復制本地的文件到遠程服務器:
[root@desktop huage]#scp -P 22 /home/huage/001 root@9.9.9.9:/home/
將本機的/home/huage/001文件拷貝到服務器的/home/目錄
4、復制本地的目錄到遠程服務器:
[root@desktop huage]#scp -vrp -P 22 /home/huage/tmp/ root@9.9.9.9:/home/
將本機的/home/huage/tmp/目錄拷貝到服務器的/home/目錄
scp用法:
-P prot(后接SSH端口,默認為22)
-v verbose(顯示詳細的傳輸過程)
-r recursion (遞歸,用于傳輸目錄及其子目錄)
-p Preserves modification times, access times, andmodes from the original file.
保持源文件的所有屬性
注:root@9.9.9.9表示以root用戶登錄9.9.9.9
總結
以上是生活随笔為你收集整理的使用openssh-clients的scp命令来传输文件的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 招行信用卡账单分期后怎么还款
- 下一篇: bbb 烧写脚本分析