Too many duplicate ssh users, how do I log them out remotely.
Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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:
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.