Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 07-02-2005, 06:42 PM   #1
LQ Newbie
Registered: Jun 2005
Location: Southern Maine
Distribution: Debian (Server), Ubuntu/Windows (Desktop)
Posts: 5

Rep: Reputation: 0
Killing an SSH Session

How can I kill somebody's SSH session (as root)? I'm a noob to killall. When I list the processes, there is USR1, USR2, and USR3. But:

saffron:~# killall USR2
USR2: no process killed
Old 07-02-2005, 07:07 PM   #2
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 128Reputation: 128
You need the name of the process, but killall is a BAD solution to killing a single ssh login. The best way (if you want to do this) is to use "ps" to find the PID of their root bash session (listed as -bash, usually) and then kill -9ing it.
Old 07-03-2005, 06:16 AM   #3
Registered: Feb 2004
Location: Kathmandu
Distribution: Redhat/fedora/Suse [Wanna Drive With Debian]
Posts: 208

Rep: Reputation: 30
OK Lets See!!

#ps -aux | grep ssh
then in the left side there will be pid like 4635 or what ever
#kill -9 pid
hope this helps you
Old 07-03-2005, 06:26 AM   #4
Senior Member
Registered: Feb 2002
Location: Szczecin, Poland
Distribution: Gentoo, Debian
Posts: 2,458

Rep: Reputation: 48
It's hard with ps to see who is connected to who..

Try netstat -tanp and locate the ESTABLISHED connection that matches.
The PID to kill is in the right hand column.
Don't use kill -9 if you can avoid it. It doesn't always allow the daemons to clean up temp files, locks etc. Use kill -TERM PID or kill -15 PID
Old 07-03-2005, 10:44 AM   #5
LQ Guru
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 128Reputation: 128
PS will allow you to see the username. I guess it depends on what you want to kill by: the user's id, or the remote host of the connection.
Old 05-27-2015, 03:51 AM   #6
LQ Newbie
Registered: May 2015
Posts: 1

Rep: Reputation: Disabled
Post My way ...

Check who is logged in
last |grep "logged in"
Check <PID> for this user
ps -aux | grep ssh | grep pts/
Kill SSH user
kill -9 <PID>

Last edited by inblue31; 05-27-2015 at 03:54 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
persistent ssh session apepost Linux - Networking 4 11-12-2005 01:16 AM
SSH Session Monitoring? totalrockage Linux - Networking 1 04-08-2005 02:01 AM
[bash] killing processes using ssh Erhnam Programming 13 02-01-2005 12:56 AM
Killing an X session twistedpair Linux - Security 1 01-07-2004 06:15 PM
killing a users ssh session acid2000 Linux - Software 6 03-17-2003 11:17 AM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:57 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration