nuliknol |
04-03-2012 08:15 PM |
close dead ssh connections
I have a DSL modem internet connection at home and when I am logged in to my dedicated internet server using ssh, the modem times out my connections when they are idle. The result is, I am accumulating dead ssh connections being idle for days (wasting system resources) that I have to kill with -9 periodically. This is how they look like when I ps:
Code:
....
root 13610 0.0 0.1 5084 1160 ? S Apr02 0:00 su -c /usr/bin/xterm
root 13612 0.0 0.2 8104 2364 ? S Apr02 0:00 \_ /usr/bin/xterm
root 13616 0.0 0.1 4772 1388 pts/29 Ss+ Apr02 0:00 \_ bash
root 14091 0.0 0.1 5084 1156 ? S Apr02 0:00 su -c /usr/bin/xterm
root 14093 0.0 0.2 8100 2488 ? S Apr02 0:00 \_ /usr/bin/xterm
root 14095 0.0 0.1 4768 1448 pts/30 Ss+ Apr02 0:00 \_ bash
root 22160 0.0 0.1 5084 1164 ? S Apr02 0:00 su -c /usr/bin/xterm
root 22162 0.0 0.2 8100 2480 ? S Apr02 0:00 \_ /usr/bin/xterm
root 22164 0.0 0.1 4768 1384 pts/32 Ss+ Apr02 0:00 \_ bash
root 6946 0.0 0.1 5084 1156 ? S Apr03 0:00 su -c /usr/bin/xterm
root 6948 0.0 0.2 8100 2360 ? S Apr03 0:00 \_ /usr/bin/xterm
root 6950 0.0 0.1 4768 1388 pts/25 Ss+ Apr03 0:00 \_ bash
root 16522 0.0 0.1 5084 1160 ? S Apr03 0:00 su -c /usr/bin/xterm
root 16524 0.0 0.2 8100 2484 ? S Apr03 0:00 \_ /usr/bin/xterm
root 16526 0.0 0.1 4772 1392 pts/36 Ss+ Apr03 0:00 \_ bash
root 22133 0.0 0.1 5088 1156 ? S Apr03 0:00 su -c /usr/bin/xterm
root 22135 0.0 0.2 8100 2364 ? S Apr03 0:00 \_ /usr/bin/xterm
root 22137 0.0 0.1 4768 1388 pts/40 Ss+ Apr03 0:00 \_ bash
root 28787 0.0 0.1 5084 1156 ? S Apr03 0:00 su -c /usr/bin/xterm
root 28789 0.0 0.2 8100 2488 ? S Apr03 0:00 \_ /usr/bin/xterm
root 28791 0.0 0.1 4768 1388 pts/43 Ss+ Apr03 0:00 \_ bash
[root@newze ~]#
I know I can setup ssh client with keep-alive and it will send some data to avoid the connection being expired by the firewall of the modem, but I don't want this (since it is not a clean solution). I want the ssh daemon to kill idle connections and the resulting child processes automatically after some inactivity period (which I can configure somewhere). Is this possible?
My OS is a bit old: centos-release-5-2.el5.centos , hope this is not an issue, I just can't upgrade this server right now, its a productive environment.
Will appreciate any comments very much on this case.
Thanks
|