[Linux study notes] use nc to transfer files between two hosts (no password required)
Source: Internet
Author: User
[Linux study notes] using nc to transfer files between two hosts (no password required) generally, scp can be used to transfer files between two hosts, however, when no trust relationship is established between hosts, scp needs to enter a password each time, which is not very convenient to use... [Linux study notes] using nc to transfer files between two hosts (no password required) generally, scp can be used to transfer files between two hosts, however, when no trust relationship is established between hosts, scp needs to enter a password each time, which is not very convenient to use. This document introduces a simple method of transferring files between two hosts without a password-with the help of the Linux nc tool, the convenience is as follows: 1) the nc tool is usually installed by default in Linux, no additional installation required; 2) No password is required for file transfer. Disadvantage: you need to enter a command on both machines. ^_^ 1. what is nc? Nc is short for netcat. for what is nc, man says: arbitrary TCP and UDP connections and listens nc allows you to conveniently listen on any TCP/UDP port and establish a connection, port scanning, and so on. That is, nc can either listen to the specified port as the server in TCP or UDP mode, or initiate a TCP connection or UDP packet as the client. The following describes how to use TCP connections to transfer files between hosts. There are many nc control parameters. common parameters are listed below: 1)-l is used to specify that nc will be in listening mode. If this parameter is specified, the nc is used as the server to listen and accept the connection, instead of initiating a connection to another address. 2)-p Specifies the port to be used by the nc. If-l is specified,-p specifies the listening port. if-l is not specified, a connection is initiated to this port. Note: The target port to be connected by nc can be an integer or a service name. in this case, nc maps the name to a well-known port (you can use cat/etc/services to view the ing between these ports and service names). 3)-s Specifies the source IP address for sending data, which is applicable to multiple Nic Machines. 4)-u specifies that nc uses UDP protocol. the default value is TCP 5)-v outputs interaction or error information, this is especially useful for beginners. use nc to transmit data between hosts has been introduced to nc. it is estimated that many people already know how to use nc to transfer files between two machines. The implementation process is briefly described here. 1) listen to the specified port [plain] nc-l-p 8210> demo.txt # listen to the TCP connection on the local port 8210 on the machine of the data receiver, write the received data to the text file nc-l-p 8210> demo.tar.bz2 # listen on the TCP connection on port 8210 of the local machine and write the received data into a compressed file. 2) to the specified ip address (ip + port) on the data sender machine) send data in TCP mode [plain] nc dest_ip 8210 <demo.txt # send the demo.txt file nc dest_ip 8210 to the 8210port of the machine whose IP is dest_ip <$ (tar-jcvf demo.tar.bz2 demo.txt) -v print error message receiver: nc-v-l-p 8210 sender: nc-v dest_ip 8210 Note: When using nc to transfer files, pay attention to the operation order. the receiver first listens to the port, Sender sends data to the port on which the worker is located. Otherwise, the message fails to be sent. ==================== EOF ============================
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.