如何清除SSH ProxyCommand打开的连接?

Chr*_*ess 4 linux ssh proxy netcat

我有一个Web服务器WWW1和一个前置代理PRX.我使用SSH ProxyCommand通过PRX(私有+公共IP)连接到WWW1的内部IP(私有IP).对于某些连接(并非所有连接),我看到在完成后网络连接保持打开状态.这些加起来!

的〜/ .ssh /配置

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
Run Code Online (Sandbox Code Playgroud)

在PRX上,此时lsof | grep WWW1:ssh显示124个打开的连接.在WWW1上,相同的命令显示243个打开的连接.WWW2,WWW3等有类似的开放连接.

WWW1和PRX是Debian.客户端连接来自Debian,Ubuntu和OSX10.6.我使用Emacs Tramp但是我没有特殊配置(AFAIK)~/.ssh/config.

我担心内部端口耗尽,理想情况下我希望这些连接能够在没有干预的情况下清理自己.理想情况下,通过配置它们来自杀; 失败的命令我可以杀死旧进程很好!

Rio*_*Rio 10

更好的方法是使用-WSSH选项,所以你可以放

 ProxyCommand ssh -q -a -x PRX -W %h:22
Run Code Online (Sandbox Code Playgroud)

代替

 ProxyCommand ssh -q -a -x PRX nc %h 22
Run Code Online (Sandbox Code Playgroud)

这样你就可以摆脱依赖nc.


seh*_*ehe 5

不知道这是否重要,但我用nc -w 1 %h %p