How to purge connections left open by SSH ProxyCommand?

0

I have a webserver WWW1 and a front-facing proxy PRX. I use SSH ProxyCommand to connect to WWW1's internal IP (private IP) via PRX (private+public IP). For some connections (not all) I see a network connection left open after I'm finished. These add up!

~/.ssh/config

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

On PRX, lsof | grep WWW1:ssh shows 124 open connections at the moment. On WWW1, the same command shows 243 open connections. There are similar open connections for WWW2, WWW3 etc.

WWW1 and PRX are Debian. Client connections are coming from a mix of Debian, Ubuntu and OSX10.6. I use Emacs Tramp but this has no special configuration (AFAIK) outside of my ~/.ssh/config.

I'm concerned about running out of internal ports, and ideally I want these connections to clean themselves up without intervention. Ideally by configuring them to kill themselves off; failing that a command I can kill old processes with is fine!

Chris Burgess

Posted 2011-04-06T20:57:51.057

Reputation: 227

This question, which I initially thought better suited for SuperUser, earned a Tumbleweed badge here for lack of response after some weeks. I reposted it verbatim on StackOverflow and had a solution in five minutes: http://stackoverflow.com/questions/5816489/how-to-purge-connections-left-open-by-ssh-proxycommand

– Chris Burgess – 2011-04-28T10:11:40.467

Answers

1

Add -w 1 to nc parameters.

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

Chris Burgess

Posted 2011-04-06T20:57:51.057

Reputation: 227

Credit for this answer to sehe @ stackoverflow. – Chris Burgess – 2011-05-06T04:05:07.750