scp命令

weixin_34378969發表於2017-08-30

scp是 secure copy的縮寫, scp是linux系統下基於ssh登陸進行安全的遠端檔案拷貝命令。
usage: scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] #大寫的P,指定埠號 [-S program] [[user@]host1:]file1 ... [[user@]host2:]file2
-r: 遞迴複製整個目錄。
-P: 大寫的P,指定埠號


從本地複製檔案到伺服器

  • 複製本地檔案到伺服器特定目錄下
    $ scp /work/myfile.txt user@10.10.22.222:/user/

  • 複製本地檔案到伺服器特定目錄下,不指定使用者名稱
    $ scp /work/myfile.txt 10.10.22.222:/user/

  • 複製本地檔案到伺服器特定目錄下,並修改檔名字
    $ scp /work/myfile.txt user@10.10.22.222:/user/newname.txt

  • 複製本地檔案到伺服器特定目錄下,並修改檔名字,不指定使用者名稱
    $ scp /work/Kmyfile.txt 10.10.22.222:/user/newname.txt

複製本地目錄到伺服器

  • 指定了使用者名稱
    $ scp -r /work/ user@10.10.22.222:/user/

  • 沒有指定了使用者名稱
    $ scp -r /work/ 10.10.22.222:/user/

複製伺服器檔案到本地

  • 複製伺服器檔案到本地,指定了使用者名稱
    $ scp user@10.10.22.222:/user/myfile.txt /work/

  • 沒有指定了使用者名稱
    $ scp 10.10.22.222:/user/myfile.txt /work/

複製伺服器檔案目錄到本地

  • 指定了使用者名稱
    $ scp -r user@10.10.22.222:/user/ /work/

  • 沒有指定了使用者名稱
    $ scp -r 10.10.22.222:/user/ /work/

相關文章