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
常見命令展示
scp命令的實際應用概述:
從本地服務器復制到遠程服務器:
(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個沒有指定用戶名,命令執行后需要輸入用戶名和密碼