linux scp 學習

scp是secure copy的簡寫,用於在Linux下進行遠程拷貝文件的命令, scp傳輸是加密的,可能會稍微影響一下速度。另外,scp還非常不佔資源,不會提高多少系統負荷,在這一點上,rsync就遠遠不及它了。雖然 rsync比scp會快一點,但當小文件衆多的情況下,rsync會導致硬盤I/O非常高,而scp基本不影響系統正常使用.

usage: scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
           [-l limit] [-o ssh_option] [-P port] [-S program]
           [[user@]host1:]file1 ... [[user@]host2:]file2
 
-q:  quiet
-r:   recuersive
-p:   properity
-v:   verbose
-i:   identity_file      【從指定文件中讀取傳輸時使用的密鑰文件,此參數直接傳遞給ssh】 
-P:  port

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個指定了文件名  

2、複製目錄

命令格式:

scp -r local_folder remote_username@remote_ip:remote_folder  

或者

scp -r local_folder remote_ip:remote_folder  

第1個指定了用戶名,命令執行後需要輸入用戶密碼

第2個沒有指定用戶名,命令執行後需要輸入用戶名和密碼

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章