Kick Linux SSH User

Find the PTS connection number of the logged in user that you wish to kick:

zero_serv:~ # who
root tty1 Sep 19 08:13
root pts/0 Jan 18 12:59 (
root pts/1 Jan 18 13:07 (

In this example, we want to kick the ‘root’ user that is on ‘pts/1′. (Notice that the connections are labeled by IP)

Issue the command:

zero_serv:~ # ps x | grep ssh
2973 ? Ss 0:00 /usr/sbin/sshd -o PidFile=/var/run/
8006 ? Ss 0:00 sshd: root@pts/0
8068 ? Ss 0:00 sshd: root@pts/1
8176 pts/0 R+ 0:00 grep ssh

(Note: depending on the system, you may need to issue this: ps -aux | grep ssh)

As you can see above, PID 8068 is the culprit.

Issue the command:

zero_serv:~ # kill -9 8068
(Where 8068 is your PID)

The session will now be killed.