2

I have a Linux machine running dropbear as its SSH server. I open many SSH sessions from a client towards that machine, meanwhile the sessions are active I pull out the Ethernet cable from the server machine's DCN port so it is not possible to SSH to the server any more. But previously created SSH processes on the server keep wandering around in the system and show up in ps command etc (causing memory leak) until I reboot the machine. Is there a way to automatically clean them up and get rid of those processes in situations same as the above without doing a reboot?

4

This might be useful for others: I solved this by adding -K SECONDS flag to the start script of dropbear. This way after three tries (1 min approximately) dropbear gives up on that connection which is dead hence it will kill the associated process on the server side. See here for more info: dropbear man page

3

Two options:

  • You can just kill these processes. If you have their PIDs, just use the kill program (which you may need to run as root) to end them.
  • Since you just pulled the cable, these processes aren't receiving any data from the remote end of the connection anymore. After a while, they will notice that and die by themselves. How long this takes depends on a few configurable parameters, but by default this is about two hours
4
  • I modded your answer up. If remote sessions of the same user, which is the probability, you do not need root; PIDs are not the best, you can also kill by pseudo-tty which is far less error-prone; I would clarify about where you got the two hours (keepalive), I would add the option about TMOUT in bash. I would also introduce the user to the screen command. I simply have not got the time right now. Cheers – Rui F Ribeiro Feb 11 '16 at 10:29
  • I didn't know the how long is the time-out value. Instead I used the flages -I and -K of the dropbear in order to solve the issue. They make it possible to fix the time-out according to the needs. – coffeMug Feb 11 '16 at 12:10
  • Can using wall to broadcast a message to all terminals speed up the process because tcp write timeout is 1 minute? – Ferrybig Feb 11 '16 at 14:55
  • I should add that I was not clear enough in my question. I wanted to clean up the processes automatically not manually using kill command! – coffeMug Feb 11 '16 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.