I believe you vpser in the use of VPS will often in different VPS backup data or transfer data, most of the VPS have been installed on the Nginx or similar Web server, directly to the transfer of files to the Web server directory, Then execute on the target machine: wget http://www.vpser.net/testfile.zip on the line. The SCP command comes in handy when the Web server and FTP server are not installed on the VPS or when the method above is felt to be cumbersome.
first, what is the SCP.
The SCP is a secure copy shorthand for remote copy of files under Linux, and a similar command has CP, but the CP is only copied on the local computer, not across servers, and the SCP transmission is encrypted. may have a slight impact on speed.
second, what is the use of SCP.
1, we need to get a file on the remote server, the remote server has neither configured the FTP server, did not open the Web server, did not do the sharing, can not get the file through the regular way, only need to pass the SCP command can easily achieve the goal.
2, we need to upload the files on this machine to the remote server, the remote server does not open the FTP server or share, can not be uploaded through the normal way is, only need to pass the SCP command can be easily achieved.
Iii. methods of using SCP
1, get the files on the remote server
Scp-p 2222 root@www.vpser.net:/root/lnmp0.4.tar.gz/home/lnmp0.4.tar.gz
The upper port caps p is the parameter, 2222 indicates that the port after the SSH port is changed, and if the SSH port is not changed, you do not need to add the parameter. Root@www.vpser.net indicates that using root to log on to a remote server www.vpser.net,:/root/lnmp0.4.tar.gz represents a file on a remote server, the last face of/home/ Lnmp0.4.tar.gz represents the path and file name that is saved locally.
2, get the directory on the remote server
Scp-p 2222-r root@www.vpser.net:/root/lnmp0.4//home/lnmp0.4/
The upper port caps p is the parameter, 2222 indicates that the port after the SSH port is changed, and if the SSH port is not changed, you do not need to add the parameter. The-r parameter represents a recursive replication (that is, copying the files and directories under the directory); root@www.vpser.net indicates that using root to log on to the remote server www.vpser.net,:/root/lnmp0.4/represents the directory on the remote server, the last side of the HOME/LNMP0.4/represents the path that is saved locally.
3, upload the local files to the server
Scp-p 2222/home/lnmp0.4.tar.gz root@www.vpser.net:/root/lnmp0.4.tar.gz
The upper port caps p is the parameter, 2222 indicates that the port after the SSH port is changed, and if the SSH port is not changed, you do not need to add the parameter. /home/lnmp0.4.tar.gz represents the path and file name of the file to be uploaded locally. Root@www.vpser.net indicates that using the root user to log on to the remote server www.vpser.net,:/root/lnmp0.4.tar.gz represents the directory and file name saved on the remote server.
4, upload the local directory to the server
Scp-p 2222-r/home/lnmp0.4/root@www.vpser.net:/root/lnmp0.4/
The upper port caps p is the parameter, 2222 indicates that the port after the SSH port is changed, and if the SSH port is not changed, you do not need to add the parameter. The-r parameter represents a recursive replication (that is, copying the files and directories under the directory);/home/lnmp0.4/represents the directory to be uploaded, root@www.vpser.net means to log on to the remote server using root www.vpser.net,:/root/ LNMP0.4/represents the directory location that is saved on the remote server.
5, a number of possible useful parameters:
-V is the same as the-V meaning in most Linux commands, and is used to show progress. Can be used to view connections, authentication, or configuration errors.
-C enables compression options.
-4 forcibly use IPV4 address.
-6 forcibly use IPV6 address.
Source: http://www.ylzx8.cn/linux/linux-unix/239964.html