Linux scp 使用詳解

一般情況,本地網(wǎng)絡(luò)跟遠(yuǎn)程網(wǎng)絡(luò)進(jìn)行數(shù)據(jù)交抱,或者數(shù)據(jù)遷移,常用的有三種方法,一是ftp,二是wget /fetch 三是,rsync 大型數(shù)據(jù)遷移用rysync,其次用fetch/wget ,最次是ftp,最慢是ftp.這幾天,在忙數(shù)據(jù)遷移時(shí),用到ssh的scp方法來遷移數(shù)據(jù)。速度與效果都很好。特別是現(xiàn)在許多服務(wù)器為了安全,都會改ssh默認(rèn)的22端口,改成一個(gè)特殊的端口。所以。在scp或者sftp時(shí),就要指定通過什么端口來遷移。現(xiàn)在,特記下這個(gè)特殊端口來scp的命令。
scp -p port user@serverip:/home/user/filename /home/user/filename
以上端口p 為參數(shù),port 端口 user 為ssh user serverip 為遠(yuǎn)程服務(wù)器ip或者域名 ,/home/user/filename 為遠(yuǎn)程服務(wù)器的文件名 /home/user/filename 為本地服務(wù)服務(wù)器的文件名。該命令的作用就是將遠(yuǎn)程的filename復(fù)制到本地對應(yīng)的目錄下面。
scp 的作用真的很巨大,詳細(xì)用法,可以man scp 或者 scp –help ,下面為附上一篇 scp 使用詳解。。。linux 的 scp 命令 可以 在 linux 之間復(fù)制 文件 和 目錄;
==================scp 命令==================scp 可以在 2個(gè) linux 主機(jī)間復(fù)制文件;
命令基本格式:scp [可選參數(shù)] file_source file_target
======從 本地 復(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è)指定了文件名;* 例程:scp /home/space/music/1.mp3 root@www.cumt.edu.cn:/home/root/others/musicscp /home/space/music/1.mp3 root@www.cumt.edu.cn:/home/root/others/music/002.mp3scp /home/space/music/1.mp3 www.cumt.edu.cn:/home/root/others/musicscp /home/space/music/1.mp3 www.cumt.edu.cn:/home/root/others/music/002.mp3

  • 復(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í)行后需要輸入用戶名和密碼;* 例程:scp -r /home/space/music/ root@www.cumt.edu.cn:/home/root/others/scp -r /home/space/music/ www.cumt.edu.cn:/home/root/others/
    上面 命令 將 本地 music 目錄 復(fù)制 到 遠(yuǎn)程 others 目錄下,即復(fù)制后有 遠(yuǎn)程 有 ../others/music/ 目錄
    ======從 遠(yuǎn)程 復(fù)制到 本地======從 遠(yuǎn)程 復(fù)制到 本地,只要將 從 本地 復(fù)制到 遠(yuǎn)程 的命令 的 后2個(gè)參數(shù) 調(diào)換順序 即可;
    例如:scp root@www.cumt.edu.cn:/home/root/others/music /home/space/music/i.mp3scp -r www.cumt.edu.cn:/home/root/others/ /home/space/music/
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容