I have observed many unexpected behaviour when trying to start netcat in listen mode remotely.
1. When following command is used :
ssh email@example.com 'nc -l -k 80 &'
I observed that the first tcp connection to this listener from any client fails. When trying to establish connection, the listener issues a FIN packet and closes the connection. But when trying to connect once more, connection gets established. I noted some problem with the file descriptors and when I used -d option while starting the netcat :
ssh firstname.lastname@example.org 'nc -d -l -k 80 &'
, this problem gets solved. But I couldn't understand what exactly causes this issue. My question is why does netcat behave differently when executed remotely using ssh.
Another problem I noted is the verbal mode doesn't work.
ssh email@example.com 'nc -l -v -k 80 &'
This doesn't even start netcat when -v is used.