kick/force logout other users from SSH shell

Sometimes you just want to kick or force logout other users on the SSH sell like bash. There are various reason for this: maybe you just want to eradicate your double login, maybe you own a server and allow other users to login to your server and this user just long enough using the server that make you pissed of or this user had run a process that eat a lot of server resources. So, here’s a way to kick that particular user:

Login as root to your SSH server

use “w” command to check which user logged in which terminal and currently running what command

w command resultAs you can see in the above screenshot, there are 2 root users currently logged in the server. The first “root” logged in via “pts/0” virtual terminal and currently running “htop” command (see in “WHAT” column). Let’s say that we want to kick this “root” user in “pts/0“.

Next, we need to find the sshd process that this root user is currently use. Do type this command

ps aux| grep pts/0

ps grep pts/0note the first ssh process in the “pts/0” terminal. The process number is 2098. We just need to kill this process number to kick this other user.

kill -9 2098

To make sure, do “w” command again

w second resultYup, that user had been kicked out from the server.

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>