Linux scp命令
Linux scp 命令用於 Linux 之間複製檔案和目錄。
scp 是 secure copy 的縮寫, scp 是 linux 系統下基於 ssh 登陸進行安全的遠端檔案拷貝命令。
scp 是加密的,rcp 是不加密的,scp 是 rcp 的加強版。
語法
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
簡易寫法:
scp [可選引數] file_source file_target
引數說明:
- -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)的選項
例項
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個指定了檔名;
應用例項:
scp /home/space/music/1.mp3 root@www.runoob.com:/home/root/others/music scp /home/space/music/1.mp3 root@www.runoob.com:/home/root/others/music/001.mp3 scp /home/space/music/1.mp3 www.runoob.com:/home/root/others/music scp /home/space/music/1.mp3 www.runoob.com:/home/root/others/music/001.mp3
複製目錄命令格式:
scp -r local_folder remote_username@remote_ip:remote_folder 或者 scp -r local_folder remote_ip:remote_folder
- 第1個指定了使用者名稱,命令執行後需要再輸入密碼;
- 第2個沒有指定使用者名稱,命令執行後需要輸入使用者名稱和密碼;
應用例項:
scp -r /home/space/music/ root@www.runoob.com:/home/root/others/ scp -r /home/space/music/ www.runoob.com:/home/root/others/
上面命令將本地 music 目錄複製到遠端 others 目錄下。
2、從遠端複製到本地
從遠端複製到本地,只要將從本地複製到遠端的命令的後2個引數調換順序即可,如下例項
應用例項:
scp root@www.runoob.com:/home/root/others/music /home/space/music/1.mp3 scp -r www.runoob.com:/home/root/others/ /home/space/music/
說明
1.如果遠端伺服器防火牆有為scp命令設定了指定的埠,我們需要使用 -P 引數來設定命令的埠號,命令格式如下:
#scp 命令使用埠號 4588 scp -P 4588 remote@www.runoob.com:/usr/local/sin.sh /home/administrator
2.使用scp命令要確保使用的使用者具有可讀取遠端伺服器相應檔案的許可權,否則scp命令是無法起作用的。
相關文章
- linux之cp/scp命令+scp命令詳解Linux
- linux命令---scpLinux
- Linux SSH & SCP命令Linux
- Linux小技巧scp命令Linux
- Linux scp命令詳述Linux
- Linux命令 --- cp與scpLinux
- Linux scp命令詳解Linux
- Linux下scp命令使用Linux
- Linux的scp命令詳解Linux
- 在 Linux 下使用 scp 命令Linux
- Linux scp命令的應用Linux
- linux下scp命令詳解Linux
- 每天一個 Linux 命令(60): scp命令Linux
- Linux cp命令和scp命令使用詳解Linux
- scp命令
- Linux遠端拷貝scp命令Linux
- 常用scp命令
- ssh scp命令
- Linux 拷貝命令之高階拷貝scp命令詳解Linux
- SCP命令的使用
- scp命令基本用法
- 常見命令--SCP
- scp命令使用方法
- Linux SSH遠端檔案/目錄傳輸命令scpLinux
- linux 下 scp使用Linux
- 在 Linux 上安全傳輸檔案的 14 SCP 命令示例Linux
- 【Linux】基礎每日一命之cut&mv&scp命令Linux
- 採用scp命令在Linux系統之間copy檔案Linux
- scp傳輸檔案的命令
- Linux下scp的用法Linux
- scp命令 用於Linux之間複製檔案和目錄Linux
- Linux基礎:ssh與scpLinux
- linux-scp傳檔案Linux
- 使用scp命令在多個Linux系統間進行檔案複製Linux
- linux之間檔案傳輸scpLinux
- 在linux下使用遠端複製命令scp時會出現去掉密碼提示的方法Linux密碼
- linux-scp 遠端拷貝報錯原因Linux
- Linux scp 後臺執行傳輸檔案Linux