linux服務器ssh文件傳輸—scp使用指南
這個問題可煩惱很久了,之前用ftp傳輸文件相當麻煩,但是這次使用打ssh,則簡單有效。
在linux下一般用scp這個命令來通過ssh傳輸文件。
注:目標服務器要開啟寫入權限。
兩台服務器都要安裝有scp包

1、從服務器上下載文件
scp username@servername:/path/filename
例如scp root@192.168.0.101:/var/www/test.txt 把192.168.0.101上的/var/www/test.txt 的文件下載到當前目錄
2、上傳本地文件到服務器
scp /path/filename username@servername:/path
例如scp /var/www/test.php root@192.168.0.101:/var/www/ 把本機/var/www/目錄下的test.php文件上傳到192.168.0.101這台服務器上的/var/www/目錄中
3、從服務器下載整個目錄
scp -r username@servername:/var/www/local_dir/
例如:scp -r root@192.168.0.101:/var/www/test /var/www/
4、上傳目錄到服務器
scp -r local_dir username@servername:remote_dir
例如:scp -r test root@192.168.0.101:/var/www/ 把當前目錄下的test目錄上傳到服務器的/var/www/ 目錄
學習自:http://www.2cto.com/os/201304/205467.html