The ncat tool is a much better option in place of netcat or nc. Also, there are two versions of netcat: securityfocus.com/tools/137 and netcat.sourceforge.net - but ncat is better than those.

We think ncat is better because of it's support for multiple protocols and simultaneous connections and SSL.

The ncat tool will likely come with your nmap package.

ncat Listen

This command replaces the common netcat listener of nc -l -p 6500.

~ $ ncat -l -p 6500

See? Easy! It's exactly the same!

ncat Pipe

Piping files from MachineA to MachineB

user@machineb $ ncat -l -p 6500 | tar -xp
user@machinea $ tar -cvz -f - . | ncat machineb 6500

ncat Pipe

Piping data from MachineA to MachineB

user@machineb $ ncat -l -p 6500 > out.tgz
user@machinea $ tar -zc ~ | ncat machineb 6500


Or piping some other data, doesn't matter they're just bits on a wire.

user@machineb $ ncat -l -p 6500 | tee -a copy.out | tar -zx -C $(mktemp -d)
user@machinea $ (tar -zc -C /var/log; tail -f /var/log/syslog) | ncat machineb 6500

Now invent your own crazy examples!

ncat with SSL

The regular old netcat packages don't have this, SSL - FTW!

user@machineb $ ncat -l -p 6500 \
    --ssl --ssl-cert /etc/ssl/host.crt --ssl-key /etc/ssl/host.key \
    > out.tgz
user@machinea $ tar -zc ~ | ncat --ssl machineb 6500

ncat using SCTP or UDP

Hell yea ncat supports more than plain-old TCP.

Using UDP

Sending from MachineA to a listening MachineB, but don't forget that UDP is an "unreliable" protocol

user@machineb $ ncat -l -p 6500 --udp > out.tgz
user@machinea $ tar -zc ~ | ncat --udp machineb 6500

Using SCTP

Sending from MachineA to a listening MachineB

user@machineb $ ncat --sctp -l -p 6500 > out.tgz
user@machinea $ tar -zc ~ | ncat --sctp machineb 6500

See Also