How to Kill Inactive SSH Sessions

5 Shares Google+ 2 Facebook 1 Twitter 1 LinkedIn 1 5 Shares ×

So you’ve been disconnected from your server which resulted in an idle user session. You know this because when you used the “w" command, you see something like the following:

There are a few ways to kill idle sessions. Including editing you sshd_config. But here’s an easy after-the-fact method:

Run this command:

the output will look something like this:

Now look for the parent PID of the session – PID from the line WITHOUT the “pstree” command.

To kill session, type:

Replace 3649 with your idle ssh’s PID. Check afterwards with the “w” command.

Now to prevent this from happening in the future you can edit your server’s /etc/ssh/sshd_config and add these lines:

5 Shares Google+ 2 Facebook 1 Twitter 1 LinkedIn 1 5 Shares ×
No comments yet.

Leave a Reply

5 Shares Google+ 2 Facebook 1 Twitter 1 LinkedIn 1 5 Shares ×