1. What is scp?
Scp is short for secure copy. It is used to remotely copy files in Linux. Similar Commands include cp, but cp only Copies files on the local machine and cannot be copied across servers, scp transmission is encrypted. It may slightly affect the speed.
Ii. What is the use of scp?
1. We need to obtain a file on the remote server. The remote server neither configures the ftp server, enables the web server, nor shares the file, you only need to use the scp command to easily achieve the goal.
2. We need to upload files from the local machine to the remote server. The remote server does not enable the ftp server or share, and cannot upload files through conventional means, you only need to use the scp command to easily achieve the goal.
Iii. scp usage 1. Obtain files on the remote server
Scp-P 2222 root@www.cetnoscn.com:/root/lnmp0.4.tar.gz/home/lnmp0.4.tar.gz
The upper-case P parameter indicates the port after the SSH port is changed. If the SSH port is not changed, you do not need to add this parameter. Root@www.vpser.net represents using the root user to log on to the remote server www.vpser.net,:/root/lnmp0.4.tar.gz represents the file on the remote server, and the last/home/lnmp0.4.tar.gz represents the path and file name saved locally.
2. Obtain the directory on the remote server
Scp-P 2222-r root @Www.cetnoscn.com:/Root/lnmp0.4 // home/lnmp0.4/
The upper-case P parameter indicates the port after the SSH port is changed. If the SSH port is not changed, you do not need to add this parameter. -The r parameter indicates recursive replication (that is, copying the files and directories under the Directory); root @Www.cetnoscn.comIndicates using the root user to log on to the remote server.Www.cetnoscn.com,:/Root/lnmp0.4/indicates the directory on the remote server, and the last/home/lnmp0.4/indicates the path saved locally.
3. upload local files to the server
Scp-P 2222/home/lnmp0.4.tar.gzRoot @Www.cetnoscn.com:/Root/lnmp0.4.tar.gz
The upper-case P parameter indicates the port after the SSH port is changed. If the SSH port is not changed, you do not need to add this parameter. /Home/lnmp0.4.tar.gz indicates the path and file name of the local file to be uploaded. The root@www.vpser.net represents using the root user to log on to the remote server www.vpser.net, And:/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.cetnoscn.com:/Root/lnmp0.4/
The upper-case P parameter indicates the port after the SSH port is changed. If the SSH port is not changed, you do not need to add this parameter. -The r parameter indicates recursive replication (that is, copying the files and directories under this directory);/home/lnmp0.4/indicates the directory to be uploaded, root @Www.cetnoscn.comIndicates using the root user to log on to the remote server.Www.cetnoscn.com,:/Root/lnmp0.4/indicates the directory location saved on the remote server.
5. Several useful parameters:
-V is the same as-v in most linux commands. It is used to display the progress. It can be used to view the connection, authentication, or configuration error.
-C enable compression options.
-4 Use the IPV4 address forcibly.
-6 Use IPV6 addresses forcibly.