2

I wonder if i can disconnect a specific ssh client from ssh server?

Can we do that?

Thanks in advance...

3
  • 1
    Seems like a duplicate of unix.stackexchange.com/questions/615/…
    – user535733
    Commented Aug 16, 2020 at 12:03
  • i already killed the client, but in client, it still connected to the server...
    – Zozzizzez
    Commented Aug 16, 2020 at 14:57
  • That exact case is addressed in the Stackexchange thread.
    – user535733
    Commented Aug 16, 2020 at 15:33

1 Answer 1

2

This is answered here: https://unix.stackexchange.com/questions/615/how-do-you-kick-a-benign-user-off-your-system/622#622

A copy of the steps:

There's probably an easier way, but I do this:

  1. See who's logged into your machine -- use who or w:

     > who  
     mmrozek  tty1         Aug 17 10:03  
     mmrozek  pts/3        Aug 17 10:09 (:pts/2:S.0)
    
  2. Look up the process ID of the shell their TTY is connected to:

     > ps t  
     PID   TTY      STAT   TIME COMMAND  
     30737 pts/3    Ss     0:00 zsh
    
  3. Laugh at their impending disconnection (this step is optional, but encouraged)

     > echo "HAHAHAHAHAHAHAHA" | write mmrozek pts/3
    
  4. Kill the corresponding process:

     > kill -9 30737
    

I just discovered you can combine steps 1 and 2 by giving who the -u flag; the PID is the number off to the right:

> who -u
mmrozek  tty1         Aug 17 10:03 09:01        9250
mmrozek  pts/18       Aug 17 10:09 01:46       19467 (:pts/2:S.0)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .