I have a server where a lot of ssh connections (with a certain command) will be handled. Each connection consumes a bit of memory so I aim to close sessions (and thus its shell/command) as soon as the connection drops.
I already tried in my /etc/ssh/sshd_config
TCPKeepAlive no
ClientAliveInterval 0
ClientAliveCountMax 0
and
TCPKeepAlive yes
ClientAliveInterval 1
ClientAliveCountMax 1
But when I open now a session "ssh user@server sleep.py" and then close via CTRL+C on the client side the session is still active.
My question: Why is the session still active and doesn't receive the SIGHUP signal? Anything I can do to make it work, so the shell is closed as soon as the connection drops?
What current happens:
Client: ssh user@server sleep.py
Server:
1 root 0:00 /bin/sh -c /bin/bash /etc/app/run.sh
9 root 0:00 /usr/sbin/sshd -D
36 root 0:00 sshd: git [priv]
44 git 0:00 sshd: git@notty
45 git 0:00 sh -c sleep.py
Client: pressed CTRL+C (commands exits) Server:
1 root 0:00 /bin/sh -c /bin/bash /etc/app/run.sh
45 git 0:00 sh -c sleep.py
9 root 0:00 /usr/sbin/sshd -D