LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 07-02-2005, 05:42 PM   #1
chatmasta
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:

Code:
saffron:~# killall USR2
USR2: no process killed
 
Old 07-02-2005, 06:07 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
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, 05:16 AM   #3
roopunix
Member
 
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, 05:26 AM   #4
peter_robb
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, 09:44 AM   #5
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
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, 02:51 AM   #6
inblue31
LQ Newbie
 
Registered: May 2015
Posts: 1

Rep: Reputation: Disabled
Post My way ...

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

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


Reply



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 12:16 AM
SSH Session Monitoring? totalrockage Linux - Networking 1 04-08-2005 01:01 AM
[bash] killing processes using ssh Erhnam Programming 13 01-31-2005 11:56 PM
Killing an X session twistedpair Linux - Security 1 01-07-2004 05:15 PM
killing a users ssh session acid2000 Linux - Software 6 03-17-2003 10:17 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 03:20 AM.

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