linux下载命令 scp,linux命令详解之scp命令
作用
scp命令常用于linux之間復制文件和目錄。
scp是secure copy的縮寫, scp是linux系統下基于ssh登陸進行安全的遠程文件拷貝命令。
格式
從本地復制到遠程
復制文件
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 -r local_folder remote_username@remote_ip:remote_folder
或者
scp -r local_folder remote_ip:remote_folder
第1個指定了用戶名,命令執行后需要再輸入密碼;
第2個沒有指定用戶名,命令執行后需要輸入用戶名和密碼;
從遠程復制到本地(與本地復制到遠程,僅參數順序替換下即可)
復制文件
scp remote_username@remote_ip:remote_file local_folder
或者
scp remote_username@remote_ip:remote_file local_file
或者
scp remote_ip:remote_file local_folder
或者
scp remote_ip:remote_file local_file
復制目錄
scp -r remote_username@remote_ip:remote_folder local_folder
scp -r remote_ip:remote_folder local_folder
參數
-1: 強制scp命令使用協議ssh1
-2: 強制scp命令使用協議ssh2
-4: 強制scp命令只使用IPv4尋址
-6: 強制scp命令只使用IPv6尋址
-B: 使用批處理模式(傳輸過程中不詢問傳輸口令或短語)
-C: 允許壓縮(將-C標志傳遞給ssh,從而打開壓縮功能)
-p:保留原文件的修改時間,訪問時間和訪問權限
-q: 不顯示傳輸進度條
-r: 遞歸復制整個目錄
-v:詳細方式顯示輸出。scp和ssh(1)會顯示出整個過程的調試信息,這些信息用于調試連接,驗證和配置問題
-c cipher: 以cipher將數據傳輸進行加密,這個選項將直接傳遞給ssh
-F ssh_config: 指定一個替代的ssh配置文件,此參數直接傳遞給ssh
-i identity_file: 從指定文件中讀取傳輸時使用的密鑰文件,此參數直接傳遞給ssh。
-l limit: 限定用戶所能使用的帶寬,以Kbit/s為單位。
-o ssh_option: 如果習慣于使用ssh_config(5)中的參數傳遞方式
-P port:注意是大寫的P, port是指定數據傳輸用到的端口號
-S program: 指定加密傳輸時所使用的程序,此程序必須能夠理解ssh(1)的選項
實例
把當前目錄下的文件復制到遠程/test/目錄下
[root@VM_0_13_centos test]# ls
a.txt
[root@VM_0_13_centos test]# scp -P 62255 a.txt root@123.207.164.126:/test/
a.txt 100% 3 0.0KB/s 00:00
把當前目錄下的文件復制到遠程/test/目錄下,并重命名為b.txt
[root@VM_0_13_centos test]# scp -P 62255 a.txt root@123.207.164.126:/test/b.txt
a.txt 100% 3 0.0KB/s 00:00
把當前目錄復制到遠程/test/下
[root@VM_0_13_centos test]# ll
total 8
-rw-r--r-- 1 root root 3 Mar 11 21:19 a.txt
drwxr-xr-x 2 root root 4096 Mar 11 21:59 foo
[root@VM_0_13_centos test]# scp -r -P 62255 foo root@123.207.164.126:/test
把遠程/test/目錄下的c.txt復制到當前目錄
[root@VM_0_13_centos test]# ls
a.txt foo
[root@VM_0_13_centos test]# scp -P 62255 root@123.207.164.126:/test/c.txt /test
c.txt 100% 2 0.0KB/s 00:00
[root@VM_0_13_centos test]# ls
a.txt c.txt foo
把遠程的文件復制到當前/test/目錄下,并重命名為d.txt
[root@VM_0_13_centos test]# scp -P 62255 root@123.207.164.126:/test/c.txt /test/d.txt
c.txt 100% 2 0.0KB/s 00:00
[root@VM_0_13_centos test]# ls
a.txt c.txt d.txt foo
把遠程目錄foo2復制到當前目錄下
[root@VM_0_13_centos test]# scp -r -P 62255 root@123.207.164.126:/test/foo2 /test
[root@VM_0_13_centos test]# ls
a.txt c.txt d.txt foo foo2
本文固定鏈接:心知博客 ? linux命令詳解之scp命令
本站內容除特別標注外均為原創,歡迎轉載,但請保留出處!
創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的linux下载命令 scp,linux命令详解之scp命令的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: (DFS)四分树
- 下一篇: (递归3)最大公约数