You should also know about the so-called "netcat mode" in OpenSSH: -W host:port Requests that standard input and output on the client be forwarded to host on port over the secure channel. Implies -N, -T, ExitOnForwardFailure and ClearAllForwardings. Works with Protocol version 2 only.
I only discovered this recently - I was using a literal "nc %h %p" rather than this shortcut. Also worth noting this is also extremely useful when used in your ~/.ssh/config file.
A Unix Utility You Should Know About: Netcat (2009)
31–39 of 39 posts
Re: A Unix Utility You Should Know About: Netcat (2009)
#32Stupid LAN trick: you can combine nc with pbcopy/pbpaste for distributed copy/paste on macs.
Re: A Unix Utility You Should Know About: Netcat (2009)
#33On a related note it's always annoyed me when people use "telnet" when they mean "make a TCP connection" as in "can you telnet to the port?"
Re: A Unix Utility You Should Know About: Netcat (2009)
#34Be aware that GNU netcat and BSD netcat are incompatible. Many a time have I attempted to cat a file from a Mac to a PC running Linux, only to have found that Nothing Happens (tm). I just recently realized that installing BSD netcat on Linux solves the problem. Not sure what the actual incompatibility is, just a heads up.
https://github.com/pflanze/chj-bin/blob/master/netcat-get https://github.com/pflanze/chj-bin/blob/master/netcat-push https://github.com/pflanze/chj-bin/blob/master/netcat-receiv... https://github.com/pflanze/chj-bin/blob/master/netcat-serve-...
(They use 'have' from here: https://github.com/pflanze/chj-bin/blob/master/have )
[1] for example my way to transfer files between servers: https://github.com/pflanze/chj-bin/blob/master/netoffer (which depends on netfetch from the same place)
Re: A Unix Utility You Should Know About: Netcat (2009)
#35Re: A Unix Utility You Should Know About: Netcat (2009)
#36Stupid LAN trick: you can combine nc with pbcopy/pbpaste for distributed copy/paste on macs.
Re: A Unix Utility You Should Know About: Netcat (2009)
#37Earlier quoted context omitted.
I only discovered this recently - I was using a literal "nc %h %p" rather than this shortcut. Also worth noting this is also extremely useful when used in your ~/.ssh/config file.
Can you give an example of how you'd use it in your config?
Host
Hostname
User gateway
ForwardAgent yes
Host 10.0.*
User
ProxyCommand ssh -W %h:%p
Where bastion is the NAT/Bastion SSH host for my infrastructure. 10.0.* are internal IP addresses, which don't work on my network, but get passed through to the bastion (where they do work). Pretty handy as I can just "ssh "Re: A Unix Utility You Should Know About: Netcat (2009)
#38Be aware that GNU netcat and BSD netcat are incompatible. Many a time have I attempted to cat a file from a Mac to a PC running Linux, only to have found that Nothing Happens (tm). I just recently realized that installing BSD netcat on Linux solves the problem. Not sure what the actual incompatibility is, just a heads up.
I just confirmed this is not the case. Could you share what you were doing?
Re: A Unix Utility You Should Know About: Netcat (2009)
#39Earlier quoted context omitted.
Can you give an example of how you'd use it in your config?
Sure. I have something like: Host Hostname User gateway ForwardAgent yes Host 10.0.* User ProxyCommand ssh -W %h:%p Where bastion is the NAT/Bastion SSH host for my infrastructure. 10.0.* are internal IP addresses, which don't work on my network, but get passed through to the bastion (where they do work). Pretty handy as I can just "ssh "