4 ms·
I would like to know if there are any advantages to use nc instead of scp ?
by nick__m 5y ago
I would like to know if there are any advantages to use nc instead of scp ?
- yjftsjthsd-h 5y agoMost obviously, the same things as its disadvantages:) With nc, you don't have encryption or authentication, which is good - faster, no keys to set up, no fingerprints to accept - and terrible - no transport encryption, no data integrity verification, no access control except for at the network layer. Also, slight difference in how you use them: scp operates on files, nc on streams. But you can just pipe over SSH, so that's not a big difference IMO.
- UI_at_80x24 5y agoYou don't need an account on the target system. Target PC opens a port and starts listening (outputting to file) Sending machine establishes a connection to the listening port, and starts copying the file. Example (hide a file transfer as DNS traffic) Listening computer: nc -l -u -p 53 > output.file Sending computer: cat original.file > nc -u [destination ip address] 53 In this case you'd be dumb not to encrypt the file before transit. And as I mentioned already make sure you have a hash of the original. You can also use TCP. These are sneaky/simple ways to move files around. Downside: You need to poke a hole in a firewall, but options exist for that too. ssh/scp downside: You need an account on target PC to connect to. nc downside: you need an open port on the listening PC.
- ducktective 5y agoThanks! - Your 'sending' snippet should use | instead of >. - ports 1-1023 are privileged.
- UI_at_80x24 5y agoOops, you're right about the pipe.. I thought that looked a bit wrong, but ignored my gut. Privileged port: I'm root anyway. =) I can't make it too easy on these kids.
- UI_at_80x24 5y agoI forgot to mention. 1 tremendous advantage to netcat: SPEED. This is the only "real-world" way to test line speed. 0 overhead, no faffing about services. If you can't get line-rate speed on your LAN with this your hardware needs to be looked at. iperf is handy, netcat is raw and real.