How to clear connections left by open SSH ProxyCommand?

I have a WWW1 web server and an external PRX proxy. I am using SSH ProxyCommand to connect to the internal IP address (private IP address) of WWW1 via PRX (private + public IP). For some connections (not for everyone), I see that the network connection remains open after I have finished. They add up!

~ / .ssh / configuration

Host * ServerAliveInterval 5 ControlMaster auto ControlPath ~/.ssh/master-% r@ %h:%p Host WWW1 WWW2 WWW3 User foo ProxyCommand ssh -q -a -x PRX nc %h 22 IdentityFile ~/.ssh/id_foo_WWWx 

In PRX, lsof | grep WWW1:ssh lsof | grep WWW1:ssh shows 124 open connections at the moment. In WWW1, the same command shows 243 open connections. Similar open connections for WWW2, WWW3, etc.

WWW1 and PRX - Debian. Client connections come from Debian, Ubuntu, and OSX10.6. I use Emacs Tramp, but I do not have a special configuration (AFAIK) outside of my ~/.ssh/config .

I am concerned about the lack of internal ports, and ideally I want these connections to be cleared without interference. Ideally, tuning them to kill yourself; otherwise, the command with which I can kill old processes is fine!

+4
source share
2 answers

I don't know if this is important, but I use nc -w 1 %h %p

+4
source

The best way would be to use the -W option for SSH, so you could put

  ProxyCommand ssh -q -a -x PRX -W %h:22 

instead

  ProxyCommand ssh -q -a -x PRX nc %h 22 

This way you also get rid of nc dependency.

+10
source

All Articles