Hostxpeed
Login Get Started →
Server Management

How to Kick a User from Server

3 min read
29 views
Jun 13, 2026

Prerequisites

Before kicking a user, make sure you have:

  • SSH access to your VPS
  • Root or sudo privileges

Step 1: Identify the User to Kick

Connect to your VPS:

ssh hxroot@YOUR_SERVER_IP -p 22
who

Example output:

hxroot   pts/0        2026-04-29 09:30 (203.0.113.45)
john     pts/1        2026-04-29 10:15 (192.168.1.100)

Note the terminal (TTY) – in this case pts/1.

Step 2: Kill the User's Session

Using pkill with TTY:

sudo pkill -9 -t pts/1

Using skill (if available):

sudo skill -KILL -u john

Using kill with process ID:

ps aux | grep john
sudo kill -9 PID

Step 3: Verify User is Disconnected

who

The user should no longer appear in the list.

Kill All User Sessions (Logout User Completely)

sudo pkill -u john

Kill All User Sessions Except Your Own

Find your own TTY:

who am i

Then kill all others:

for tty in $(who | grep -v "$(who am i | awk '{print $2}')" | awk '{print $2}'); do
    sudo pkill -9 -t $tty
done

Prevent User from Logging Back In (Temporarily)

Lock the user account:

sudo passwd -l john

Unlock later:

sudo passwd -u john

Kill Idle Sessions Automatically

Add to /etc/ssh/sshd_config:

ClientAliveInterval 300
ClientAliveCountMax 2

Restart SSH:

sudo systemctl restart sshd

Idle sessions will disconnect after 10 minutes.

✅ User has been kicked from the server.

Was this article helpful?