省朝夕

           

          Linux-scp

          scp命令


          用途 

          實現本機文檔(文件夾)與遠程機器的相互拷貝。即:copy from local to remote,也可以copy from remote to local. 是基于ssh實現的安全保密的傳輸模式。

          用法

          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/hejianchao/demo/a.tar.gz root@www.Amachine.com:/home/anotherUser/demo
          scp /home/hejianchao/demo/b.tar.gz root@www.Amachine.com:/home/anotherUser/b.tar.gz
          scp /home/hejianchao/demo/c.tar.gz www.mydomain.com:/home/anotherUser/demo
          scp /home/hejianchao/demo/d.tar.gz www.mydomain.com:/home/anotherUser/demo/d.tar.gz
          (2) 復制目錄:
          命令格式:
                scp -r local_folder remote_username@remote_ip:remote_folder
          或者 scp -r local_folder remote_ip:remote_folder
          第1個指定了用戶名,命令執行后需要輸入用戶密碼;
          第2個沒有指定用戶名,命令執行后需要輸入用戶名和密碼;
          實例:
          scp -r /home/hejianchao/demo/ root@www.Amachine.com:/home/anotherUser/demo/
          scp -r /home/hejianchao/demo/ www.Amachine.com:/home/anotherUser/demo/
          效果:把本機demo 目錄 復制 到 遠程 demo 目錄下。
          2>從遠程服務器復制到本地服務器
          從遠程復制到本地的scp命令與上面的命令十分類似,只要將從本地復制到遠程的命令后面2個參數互換順序就行了。
          例如:
          scp root@www.Amachine.com:/home/anotherUser/demo/a.zip /home/hejianchao/demo/a.zip
          scp www.Amachine.com:/home/anotherUser/demo/ -r /home/hejianchao/demo/
          更多詳情,參見:man scp.


          posted on 2013-04-09 23:17 hejianchao 閱讀(161) 評論(0)  編輯  收藏 所屬分類: 一天一命令

          導航

          統計

          留言簿

          文章分類

          文章檔案

          搜索

          最新評論

          主站蜘蛛池模板: 通化县| 尚志市| 民县| 通城县| 宝山区| 梁山县| 海城市| 宜章县| 新河县| 鹤岗市| 丹巴县| 清新县| 新密市| 钟山县| 郴州市| 东阳市| 颍上县| 黄骅市| 隆尧县| 黑水县| 鄂尔多斯市| 德清县| 潞城市| 息烽县| 松原市| 肇庆市| 阿拉善盟| 景泰县| 北流市| 略阳县| 五常市| 汝城县| 尉犁县| 咸丰县| 江门市| 玉林市| 丰顺县| 凭祥市| 巩义市| 慈溪市| 上高县|