LinuxQuestions.org
Help answer threads with 0 replies.
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, 12: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, 12:47 AM   #2
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
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, 12:53 AM   #3
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,721

Rep: Reputation: 1704Reputation: 1704Reputation: 1704Reputation: 1704Reputation: 1704Reputation: 1704Reputation: 1704Reputation: 1704Reputation: 1704Reputation: 1704Reputation: 1704
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, 10: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-18-2014, 11:06 PM   #5
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
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-18-2014, 11:08 PM   #6
haertig
Senior Member
 
Registered: Nov 2004
Distribution: Debian, Ubuntu, LinuxMint, Slackware, SysrescueCD, Raspbian, Arch
Posts: 2,331

Rep: Reputation: 357Reputation: 357Reputation: 357Reputation: 357
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, 08:19 AM   #7
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
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 02: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 03:23 AM
how do I log out remotely? kleptophobiac Linux - Software 6 01-28-2004 10:16 PM
Kick and log users on SSH Quantum0726 Linux - Security 5 01-02-2004 09:10 AM
Non-root users can log in to SSH but not read Home Directory? Bizanshee Linux - Software 1 09-18-2002 07:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:51 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