利用scp 遠端上傳下載檔案/資料夾,ssh上傳下載檔案,兩個伺服器檔案互傳
阿新 • • 發佈:2019-01-07
利用scp傳輸檔案
1、從伺服器上下載檔案
scp [email protected]:/path/filename
例如scp [email protected]:/home/kimi/test.txt 把192.168.0.101上的/home/kimi/test.txt
的檔案下載到當前目錄
2、上傳本地檔案到伺服器
scp /path/filename [email protected]:/path
例如scp /var/www/test.php [email protected]:/var/www/ 把本機/var/www/目錄下的test.php檔案
上傳到192.168.0.101這臺伺服器上的/var/www/目錄中
3、從伺服器下載整個目錄
scp -r [email protected]:remote_dir/ local_dir/
例如:scp -r [email protected] /home/kimi/test /home/kimi/
4、上傳目錄到伺服器
scp -r local_dir [email protected]:remote_dir
例如:
scp -r test [email protected]:/var/www/ 把當前目錄下的test目錄上傳到伺服器
的/var/www/ 目錄
5、兩個伺服器檔案互傳
從另外一臺遠端伺服器下載檔案到當前伺服器
scp -r [email protected]遠端伺服器ip:遠端伺服器檔案路徑 當前伺服器檔案路徑
例如 :scp [email protected]:/data/wwwroot/default/website.tar.bz2 /data/wwwroot/default/
從當前伺服器上傳到另一臺遠端伺服器
scp 當前伺服器檔案路徑 [email protected]遠端伺服器ip:遠端伺服器檔案路徑
scp /path/filename [email protected] 138.116.217.81:/path