Today I need to copy a large file (about 20G) to my router’s hard drive. Usually people think of using the scp command. scp is short for ssh copy. I tried it and the speed is only 5M or so. It took almost an hour to finish copying, which was unbearable. So I looked into how to speed up the transfer speed.

So why is it slow? The main reason is that ssh encrypts 🔐 the communication content, the sender has to encrypt and the receiver has to decrypt. But my receiver is a used ASUS AC1900P with dual-core 1.4G main frequency, which does not support AES hard decryption. So when decrypting ssh data, it’s more difficult. The slow speed is also normal. So we need to find a way to transfer without encryption. In fact, my home LAN can be seen as a secure environment, and encrypted transmission is really unnecessary.

There are many ways to transmit in clear text. For example, you can use http protocol, or you can use ftp protocol. However, general http servers do not support uploading files by default, and ftp servers are even more difficult to configure. The easiest way is to use netcat.

netcat is very powerful and can perform simple network communication.

After installing netcat you need to wait on the receiving end to receive the file.

nc -l -p 1234 > bak.tgz

nc is the command for netcat, a few platforms need to write it as netcat. -l is the port to listen on, waiting for data to be received. -p 1234 is the port number to listen on, here we are listening on port 1234. followed by > bak.tgz means that the received data will be redirected to the bak.tgz file. Without this redirection, netcat will output the received data to stdout.

Next you can send the transport set on the sender side.

nc 1234 < bak.tgz

nc is followed by the IP and port number of the receiving end. Then < bak.tgz is another redirect, meaning that the contents of the bak.tgz file are piped to nc. nc will first establish a tcp connection with the receiver, and then pass the entire file slowly.

I tried it myself, and the transfer speed was stable at around 30M. Considering that I have a mechanical hard drive, plus the network loss and CPU operation, this is not a bad speed.