NC use 2, use NC transfer files and directory

Using NC transport files is more convenient because it does not use SCP and RSYNC input password.

Send the RPM file on device A to device B

Pay attention to the process order, the receiver listens on the port first, and the sender sends data to the port of the device where the receiver is located.

Step 1, first start to monitor the receiving file on machine B, the format is as follows

This means that the data received by LAI 9995 is recorded in a file file (here the file name is optional)

nc -l port > file

nc -l 9995 > zabbix.rpm


Step 2Send data to device port 9995 on the device, and send the next RPM packet to the past

nc 9995


After device B is received, it automatically exits monitoring. The file size is the same as the device size.


Method 2, transfer files (run send command first)

Step 1, first run the file command on device b

The following command specifies that the file is sent on local port 9992

nc-l 9992


Step 2, connect device B to device, take the receiving file

The following command indicates that the file is obtained by plugging into port 9992 of device B and the file is stored in this directory. File name –

nc 9992>


Method 3: View the transfer directory (the method for sending files is the same)

Step 1, B device starts the screen first, as below

Device sends multiple files to device B.

The move directory must be combined with other commands such as tar

Following my test pipeline, another filename should not be configured

nc -l 9995 | tar xfvz –


Step 2, the machine filling file and connect the machine B port

Before piping, this means that all files in the current directory are packed in – then use NC to send them to device B

tar cfz – * | nc 9995


The machine is received here and decompressed automatically


Leave a Comment