1. 程式人生 > >使用SSH的scp命令列傳輸檔案到遠端伺服器

使用SSH的scp命令列傳輸檔案到遠端伺服器

使用方式如下:

1、上傳本地檔案到伺服器

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/目錄中

2、從伺服器上下載檔案

下載檔案我們經常使用wget,但是如果沒有http服務,如何從伺服器上下載檔案呢?

scp [email protected]:/path/filename /var/www/local_dir(本地目錄)

例如scp [email protected]

:/var/www/test.txt 把192.168.0.101上的/var/www/test.txt 的檔案下載到/var/www/local_dir(本地目錄)

3、從伺服器下載整個目錄

scp -r [email protected]:/var/www/remote_dir/(遠端目錄) /var/www/local_dir(本地目錄)

例如:scp -r [email protected]:/var/www/test /var/www/

4、上傳目錄到伺服器

scp -r local_dir [email protected]:remote_dir

例如:scp -r test [email protected]

:/var/www/ 把當前目錄下的test目錄上傳到伺服器的/var/www/ 目錄

--------------------- 本文來自 junzhou134 的CSDN 部落格 ,全文地址請點選:https://blog.csdn.net/m0_37138008/article/details/78283347?utm_source=copy