netcat replacement Ncat time unit


It’s common to use netcat utility to work with SSH ProxyCommand, which allows to use a bridge server, very useful when you need to connect directly to a host behind a firewall. Example:

# File: ~/.ssh/config

Host workbox
  HostName # The ip address that the bridge server can see
  User anotherusername
  IdentityFile ~/.ssh/id_rsa
  ProxyCommand ssh [email protected] nc -w 120 %h %p

I was using netcat until a couple of days, and works very smooth. Then I’ve setup a new server on another private network, behind a CentOS 7 firewall, and when I’ve tried the configuration above, I got this:

Ncat: Since April 2010, the default unit for -w is seconds, so your time of "120" is 2.0 minutes. Use "120ms" for 120 milliseconds. QUITTING.

I didn’t know, but I’m using Ncat instead of the old Netcat. I got not time to learn the differences, but I already found one. Every parameter that receives a time needs the unit. From ncat --help:

$ nc --help
Ncat 6.40 ( )
Usage: ncat [options] [hostname] [port]

Options taking a time assume seconds. Append 'ms' for milliseconds,
's' for seconds, 'm' for minutes, or 'h' for hours (e.g. 500ms).

Then, in my SSH configuration I had to change the -w param to add the time unit (ms, s, m, h, etc):

  ProxyCommand ssh [email protected] nc -w 120m %h %p