linux下载命令 scp,linux命令详解之scp命令
作用
scp命令常用于linux之間復(fù)制文件和目錄。
scp是secure copy的縮寫, scp是linux系統(tǒng)下基于ssh登陸進(jìn)行安全的遠(yuǎn)程文件拷貝命令。
格式
從本地復(fù)制到遠(yuǎn)程
復(fù)制文件
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個(gè)指定了用戶名,命令執(zhí)行后需要再輸入密碼,第1個(gè)僅指定了遠(yuǎn)程的目錄,文件名字不變,第2個(gè)指定了文件名;
第3,4個(gè)沒有指定用戶名,命令執(zhí)行后需要輸入用戶名和密碼,第3個(gè)僅指定了遠(yuǎn)程的目錄,文件名字不變,第4個(gè)指定了文件名;
復(fù)制目錄
scp -r local_folder remote_username@remote_ip:remote_folder
或者
scp -r local_folder remote_ip:remote_folder
第1個(gè)指定了用戶名,命令執(zhí)行后需要再輸入密碼;
第2個(gè)沒有指定用戶名,命令執(zhí)行后需要輸入用戶名和密碼;
從遠(yuǎn)程復(fù)制到本地(與本地復(fù)制到遠(yuǎn)程,僅參數(shù)順序替換下即可)
復(fù)制文件
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
復(fù)制目錄
scp -r remote_username@remote_ip:remote_folder local_folder
scp -r remote_ip:remote_folder local_folder
參數(shù)
-1: 強(qiáng)制scp命令使用協(xié)議ssh1
-2: 強(qiáng)制scp命令使用協(xié)議ssh2
-4: 強(qiáng)制scp命令只使用IPv4尋址
-6: 強(qiáng)制scp命令只使用IPv6尋址
-B: 使用批處理模式(傳輸過程中不詢問傳輸口令或短語)
-C: 允許壓縮(將-C標(biāo)志傳遞給ssh,從而打開壓縮功能)
-p:保留原文件的修改時(shí)間,訪問時(shí)間和訪問權(quán)限
-q: 不顯示傳輸進(jìn)度條
-r: 遞歸復(fù)制整個(gè)目錄
-v:詳細(xì)方式顯示輸出。scp和ssh(1)會(huì)顯示出整個(gè)過程的調(diào)試信息,這些信息用于調(diào)試連接,驗(yàn)證和配置問題
-c cipher: 以cipher將數(shù)據(jù)傳輸進(jìn)行加密,這個(gè)選項(xiàng)將直接傳遞給ssh
-F ssh_config: 指定一個(gè)替代的ssh配置文件,此參數(shù)直接傳遞給ssh
-i identity_file: 從指定文件中讀取傳輸時(shí)使用的密鑰文件,此參數(shù)直接傳遞給ssh。
-l limit: 限定用戶所能使用的帶寬,以Kbit/s為單位。
-o ssh_option: 如果習(xí)慣于使用ssh_config(5)中的參數(shù)傳遞方式
-P port:注意是大寫的P, port是指定數(shù)據(jù)傳輸用到的端口號(hào)
-S program: 指定加密傳輸時(shí)所使用的程序,此程序必須能夠理解ssh(1)的選項(xiàng)
實(shí)例
把當(dāng)前目錄下的文件復(fù)制到遠(yuǎn)程/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
把當(dāng)前目錄下的文件復(fù)制到遠(yuǎn)程/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
把當(dāng)前目錄復(fù)制到遠(yuǎn)程/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
把遠(yuǎn)程/test/目錄下的c.txt復(fù)制到當(dāng)前目錄
[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
把遠(yuǎn)程的文件復(fù)制到當(dāng)前/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
把遠(yuǎn)程目錄foo2復(fù)制到當(dāng)前目錄下
[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命令
本站內(nèi)容除特別標(biāo)注外均為原創(chuàng),歡迎轉(zhuǎn)載,但請(qǐng)保留出處!
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的linux下载命令 scp,linux命令详解之scp命令的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: (DFS)四分树
- 下一篇: liunx php apache2,li