Reverse ssh tunnel bound to remote socket reserves the socket address after disconnect preventing reconnecting

David Newall openssh at davidnewall.com
Fri Mar 2 20:30:02 AEDT 2018


Hi Timo,

I suspect that the reason the socket is not removed from the UNIX 
filesystem is because Linux (I assume) doesn't remove it when the socket 
is closed.  SSH probably does the same thing to create and to destroy 
UNIX-domain sockets as it does for IP sockets, namely, create using 
socket()+bind(), destroy using close().  Personally, I think it's wrong 
that the close() call doesn't remove the name, but that's something 
which is unlikely to change.

You are right, SSH could remove the name, however, as it doesn't 
(although perhaps that might change), you could work around the problem 
by removing it yourself, e.g.

sh -c 'ssh -N -T -R $(pwd)/lol.socket:127.0.0.1:4444 127.0.0.1; rm 
lol.socket' &

Regards.

David



More information about the openssh-unix-dev mailing list