When you have been disconnected from the server several times, causing the ssh session to be inactive. You know this because when you use the " w" command, you will see the following ……
In this tutorial, we will explain how to find an idle ssh process and kill it.
Identifying idle ssh sessions using pstree
There are several ways to terminate an idle ssh session. Including editing your sshd_config, but here is a simple after-the-fact method.
Run the pstree command.
The output will look like this.
To terminate an idle ssh session, type.
Replace 3649 with your idle ssh session process ID and check it with the “w” command.
Now to prevent this from happening in the future, let’s edit /etc/ssh/sshd_config and add the following two lines of configuration.
Identifying idle ssh sessions with htop
Another way to identify idle (isolated ssh sessions) is to use htop. we can see that the “top” command is still running below the inactive ssh sessions.