Environment: CentOS 6.6
When running this simple test (from myclient):
while true; do rsh myserver "echo OK"; done
After ~500 iterations, the server runs out of ports.
netstat -anp on the server shows:
tcp 0 0 myserver:1008 myclient:922 TIME_WAIT -
tcp 0 0 myserver:975 myclient:922 TIME_WAIT -
tcp 0 0 myserver:998 myclient:922 TIME_WAIT -
tcp 0 0 myserver:991 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1007 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1000 myclient:922 TIME_WAIT -
tcp 0 0 myserver:990 myclient:922 TIME_WAIT -
tcp 0 0 myserver:979 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1003 myclient:922 TIME_WAIT -
tcp 0 0 myserver:988 myclient:922 TIME_WAIT -
tcp 0 0 myserver:984 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1002 myclient:922 TIME_WAIT -
tcp 0 0 myserver:997 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1019 myclient:922 TIME_WAIT -
tcp 0 0 myserver:995 myclient:922 TIME_WAIT -
tcp 0 0 myserver:993 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1004 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1017 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1013 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1011 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1009 myclient:922 TIME_WAIT -
tcp 0 0 myserver:994 myclient:922 TIME_WAIT -
tcp 0 0 myserver:987 myclient:922 TIME_WAIT -
tcp 0 0 myserver:986 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1012 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1010 myclient:922 TIME_WAIT -
tcp 0 0 myserver:1014 myclient:922 TIME_WAIT -
tcp 0 0 myserver:996 myclient:922 TIME_WAIT -
922 is the RSH stderr port (from monitoring with wireshark).
After approximatively one minute, the sockets are closed on the server and new connections can be made.
So it seems the client or the server fails to properly close these sockets, and they just timeout.
Is this a bug in rsh ?
Any idea to work around this ? I can see BSD's rsh has a --no-stderr option, but Linux does not seem to.
rsh? Out of the box it's incredibly insecure and in almost all cases it can (and should) be replaced withssh.rshdaemon, please could you clarify what it is that you want to achieve with these manyrshinvocations. It's difficult to suggest a work-around without knowing what you're trying to do.