簡介
scp是secure copy的縮寫亲雪,Linux下進行遠程拷貝文件的命令待讳。
scp傳輸是加密的品擎。
命令格式
scp [options] [原路徑] [目標路徑]
使用
ps:指定了遠程主機的用戶名后 命令執(zhí)行完需要輸入密碼; 如果沒有指定用戶名 命令執(zhí)行完后需要輸入用戶名和密碼。48.89.189.137為測試ip揍异,瞎寫的······
從遠程拷貝文件到本地
scp remote_username@remote_ip: remote_file_location local_location
說明:
- remote_username 遠程主機的用戶名
- remote_ip 遠程主機IP
- remote_file_location 要拷貝的遠程文件的路徑
- local_location 保存遠程文件的本地路徑
實例:
scp root@48.89.189.137:/root/deploy.sh ./ //拷貝遠程主機的deploy.sh 文件到本地當前目錄下
從遠程拷貝目錄到本地
scp -r remote_username@remote_ip: remote_folder_location local_location
說明:
- -r 遞歸復制整個目錄
- remote_folder_location 要拷貝的遠程目錄的路徑
實例:
scp -r root@48.89.189.137:/root/code ./ // 拷貝遠程主機的code目錄 到本地當前目錄下
上傳本地文件到遠程指定目錄下
scp locat_file_location remote_username@remote_ip: remote_file_location
實例:
scp ./scp_test/ddd.txt root@48.89.189.137:/root/
上傳本地目錄到遠程指定目錄下
scp -r locat_folder_location remote_username@remote_ip: remote_folder_location
實例:
scp -r ./scp_test/ root@48.89.189.137:/root/