Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux uses scp command to copy files remotely and explain in detail

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Preface

Scp is the abbreviation of secure copy, and scp is a secure remote file copy command based on ssh login in Linux system. Linux's scp command copies files and directories between Linux servers.

Use syntax:

Scp [Parameter] [Source path] @ IP:/ destination path

The scp parameters are as follows:

-1: force the scp command to use the protocol ssh2

-2: force the scp command to use the protocol ssh3

-4: forces the scp command to use only IPv4 addressing

-6: force the scp command to use only IPv6 addressing

-B: use batch mode (transfer passwords or phrases are not asked during transfer)

-C: compression is allowed. (pass the-C flag to ssh to turn on compression)

-p: retain the modification time, access time and access rights of the original file.

-Q: the transmission progress bar is not displayed.

-r: copy the entire directory recursively.

-v: display the output in detail. Scp and ssh (1) show debugging information for the entire process. This information is used to debug connections, verify, and configure problems.

-c cipher: encrypts the data transfer in cipher, this option will be passed directly to ssh.

-F ssh_config: specify an alternate ssh configuration file, which is passed directly to ssh.

-I identity_file: reads the key file used for transfer from the specified file, and this parameter is passed directly to ssh.

-l limit: limits the bandwidth that users can use, in Kbit/s.

-o ssh_option: if you are accustomed to using the parameter passing method in ssh_config (5)

-P port: note that it is capitalized P, and port is the port number used to specify the data transfer.

-S program: specifies the program to be used for encrypted transmission. This program must be able to understand the options of ssh (1).

Test: server server ip192.168.43.117 backup server ip 192.168.43.200

① copies data from local to remote:

Copy the server server / tmp/ directory to the remote backup server / text directory:

Scp-r / tmp/ root@192.168.43.200: / text

View the copied data on the backup server:

② copies data from the remote to the local:

Copy the 123.log file from the backup server / text directory to the local server server / tmp/ directory:

Scp root@192.168.43.200:/text/123.log / tmp/

Scp is a command to copy files remotely under Linux, and similar commands are cp, but cp is only copied locally, not across servers, and the scp transfer is encrypted. It may affect the speed slightly. When your server hard drive becomes read-only read only system, using scp can help you move the files out. In addition, scp is also very resource-free, will not increase the system load, at this point, rsync is far less than it. Although rsync is a little faster than scp, when there are a large number of small files, rsync will cause the hard disk I _ An O to be very high, while scp basically does not affect the normal use of the system. Scp uses ssh connection and encryption to improve data security when boasting machine replication. If ssh password-free login is configured between machines, there is no need to enter a password when using scp.

Summary

The above is the whole content of this article, I hope that the content of this article has a certain reference and learning value for your study or work, if you have any questions, you can leave a message and exchange, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 269

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report