Linux_ssh remote file transfer command scp

linux_ssh remote file transfer command scp

 

1. What is SCP?

  scp is short for secure copy, a command used to copy files remotely under Linux. Similar commands to it are cp, but cp only copies locally and cannot cross servers, and scp transmission is encrypted. It may affect the speed a little.

 

2. What is the use of scp?

  1. We need to obtain a certain file on the remote server. The remote server has neither ftp server configured, no web server enabled, nor shared. When the file cannot be obtained through conventional means, it is only necessary to use the scp command to easily achieve the goal. .

  2. We need to upload the files on the local machine to the remote server. The remote server does not have ftp server or sharing enabled, and cannot be uploaded through conventional channels. It can be easily achieved by using the scp command.

 

3. How to use scp

  1. Get the file on the remote server

scp -P 2222 [email protected]:/root/lnmp0.4.tar.gz /home/lnmp0.4.tar.gz

  The uppercase P on the port is a parameter, and 2222 indicates the port after changing the SSH port. If the SSH port is not changed, you can not add this parameter. [email protected] means using root user to log in to the remote server www.vpser.net, :/root/lnmp0.4.tar.gz means the file on the remote server, the last /home/lnmp0.4.tar. gz represents the path and file name saved on the local.

 

  2. Get the directory on the remote server

 

scp -P 2222 -r [email protected]:/root/lnmp0.4/ /home/lnmp0.4/

  The uppercase P on the port is a parameter, and 2222 indicates the port after changing the SSH port. If the SSH port is not changed, you can not add this parameter. The -r parameter means recursive replication (that is, copying the files and directories under the directory); [email protected] means using the root user to log in to the remote server www.vpser.net, :/root/lnmp0.4/ means on the remote server Directory, the last /home/lnmp0.4/ represents the path saved on the local.

 

  3. Upload the local file to the server

scp -P 2222 /home/lnmp0.4.tar.gz [email protected]:/root/lnmp0.4.tar.gz

  The uppercase P on the port is a parameter, and 2222 indicates the port after changing the SSH port. If the SSH port is not changed, you can not add this parameter. /home/lnmp0.4.tar.gz indicates the path and file name of the file to be uploaded locally. [email protected] indicates that the root user is used to log in to the remote server www.vpser.net, and :/root/lnmp0.4.tar.gz indicates 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/ [email protected]:/root/lnmp0.4/

  The uppercase P on the port is a parameter, and 2222 indicates the port after changing the SSH port. If the SSH port is not changed, you can not add this parameter. The -r parameter means recursive copying (that is, copying the files and directories under the directory); /home/lnmp0.4/ means the directory to be uploaded, [email protected] means using the root user to log in to the remote server www.vpser. net, :/root/lnmp0.4/ represents the directory location saved on the remote server.

 

  5. Several parameters that may be useful:

-v means the same as -v in most linux commands, and is used to display progress. Can be used to view connection, authentication, or configuration errors.

-C Enable compression options.

-4 Force the use of IPV4 addresses.

-6 Force the use of IPV6 addresses.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326993242&siteId=291194637