LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-18-2014, 01:20 AM   #1
mxmaniac
LQ Newbie
 
Registered: Feb 2014
Posts: 26

Rep: Reputation: Disabled
Too many duplicate ssh users, how do I log them out remotely.


I'm using Debian Wheezy. And I had some issues with the client pc going to sleep, terminal session becoming unresponsive, etc. Now i've logged into ssh multiple times, and when I use the "w" command, there are 5 instances of myself logged in.

I already googled this, and tried 10+ different things, involving skill, killall, pkill, and all sorts of different options. Tried killing the user, their PID's, their pts/0, pts/2, etc. And nothing has worked. I don't get any sort of error message or anything, it just does nothing (like most successful commands do), yet I type who, or ps, again and see that nothin actually happened. Every single page I go to has a different solution and none of them work. How do I log them out? And how can I prevent lots of duplicate users from building up like this in the future if something happens on the client pc that I can't properly logout?
 
Old 02-18-2014, 01:47 AM   #2
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 2,117

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
Assuming you have root permissions on the server, kill each targeted process like this:
Code:
 sudo kill -9 <process_id>
If you're desperate and willing to throw caution to the wind, including logging yourself out and praying that ssh will successfully restart without error:
Code:
 sudo /etc/init.d/ssh restart
 
Old 02-18-2014, 01:53 AM   #3
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and Scientific Linux
Posts: 5,753

Rep: Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288Reputation: 1288
Hi,
Quote:
Originally Posted by haertig View Post
If you're desperate and willing to throw caution to the wind, including logging yourself out and praying that ssh will successfully restart without error:
Code:
 sudo /etc/init.d/ssh restart
Just want to point out that stopping sshd like this will not actually terminate existing ssh connections.

Cheers,

Evo2.
 
Old 02-18-2014, 11:00 PM   #4
mxmaniac
LQ Newbie
 
Registered: Feb 2014
Posts: 26

Original Poster
Rep: Reputation: Disabled
The
Code:
sudo kill -9 <process_id>
finally worked, although it was a struggle finding all the right PID's. I'd keep killing ones that appeared to be associated with the idle users, based on the pts/x numbers, only to find out they are still logged on. Ended up scrutinizing the branches of the pstree to figure things out.

I wish there was an easier way. Isn't there a command to kill a user session based on the pts/x number? Found a lot on google, but none actually worked.
 
Old 02-19-2014, 12:06 AM   #5
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 2,117

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
Quote:
Originally Posted by evo2 View Post
Just want to point out that stopping sshd like this will not actually terminate existing ssh connections.
You're right, it doesn't! I just tried it to verify.

I made a bad assumption about OpenSSH based on my experiences with Tectia SSH on Solaris (at work). I know a "restart" there will terminate existing ssh connections (ask me how I know this!) I learned to be very careful to type "reload" rather than "restart" when working with Tectia. I had one time where I fat-fingered the config file and the restart error'ed out and didn't start back up again. Of course, my ssh session had been killed during the restart attempt. Oops! I had to dispatch somebody to the console to fix my error and get Tectia restarted.
 
Old 02-19-2014, 12:08 AM   #6
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD
Posts: 2,117

Rep: Reputation: 330Reputation: 330Reputation: 330Reputation: 330
Quote:
Originally Posted by mxmaniac View Post
Isn't there a command to kill a user session based on the pts/x number?
Code:
 pkill -t <terminal>
 
Old 02-19-2014, 09:19 AM   #7
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,195
Blog Entries: 10

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
Code:
sudo pkill -KILL -u user
DO NOT USE THIS ON root
 
  


Reply


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
how to log ssh activity in /var/log/ssh/ssh*.log MrUmunhum Linux - Server 3 11-02-2011 03:25 AM
When using ssh: limit the number of users, that can log on, per IP address -rate tuxhats Linux - Security 24 04-17-2009 04:23 AM
how do I log out remotely? kleptophobiac Linux - Software 6 01-28-2004 11:16 PM
Kick and log users on SSH Quantum0726 Linux - Security 5 01-02-2004 10:10 AM
Non-root users can log in to SSH but not read Home Directory? Bizanshee Linux - Software 1 09-18-2002 08:01 PM


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

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration