How to Disconnect Specific Ssh Client from Ssh Server in Linux?

How to Disconnect Specific Ssh Client from Ssh Server in Linux?

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

Can we do that?

Thanks in advance...

3

1 Answer

This is answered here:

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)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Alexander Ross
Author

Alexander Ross

Alexander Ross has covered the video game industry for a decade, writing deep dives on game design, esports tournaments, VR developments, and gaming culture.