Linux 利用scp传输文件

在linux下一般可以用scp这个命令来传输文件。

1、从服务器下载文件。

scp [email protected]:/var/www/test/test.html test.html

//把139.129.37.238上的/var/www/test/test.html 的文件下载到当前目录,并指定文件名为test.html(本地目录)

2、上传本地文件到服务器。

scp /Users/wing/files/test.html  [email protected]:/var/www/test/        
#ssh非常规的22端口则使用以下命令
scp -P 22222 -r /Users/wing/files/ [email protected]:/home/wing/files      

//把本机/Users/wing/files/test.html 目录下的test.html文件上传到139.129.37.238这台服务器上的/var/www/test/目录中。

3、从服务器下载整个目录。

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

//把远程主机139.129.37.238下的/var/www/test下载到当前目录。

4、上传目录到服务器。

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

把当前目录下的test目录上传到服务器的/var/www/ 目录

你可能感兴趣的:(Linux 利用scp传输文件)