How to kill a users SSH Connection


Recommended Posts

Hi,

Yes I have been using kill however listing the processes for sshd will list ALL processes of sshd, sometimes I want to kill just 1 user and killing sshd will kill everyone which I dont want. If I want to kill every I just restart sshd with 'service sshd restart'

The only way using kill to kill sshd would be handy is if I could find out which user was using which instance of sshd so I could kill just that 1 instance of sshd. is there any way to find out what user is using what PID for sshd?

using 'w' will only display the programs a user is currently running so that doesnt work.

Anyone got any other ideas?

can't you just ps -u username (do you know their username?) this will give you the pid of their connection

[bud@<hidden> bud]$ ps -u bud

PID TTY TIME CMD

20444 ? 00:00:00 sshd

20445 pts/0 00:00:00 bash

20478 pts/0 00:00:00 ps

[bud@<hidden> bud]$

And then kill that PID ;)

  BudMan said:
can't you just ps -u username (do you know their username?) this will give you the pid of their connection

[bud@<hidden> bud]$ ps -u bud

PID TTY TIME CMD

20444 ? 00:00:00 sshd

20445 pts/0 00:00:00 bash

20478 pts/0 00:00:00 ps

[bud@<hidden> bud]$

And then kill that PID ;)

Never thought of that until now :laugh:

  BudMan said:
can't you just ps -u username (do you know their username?) this will give you the pid of their connection

[bud@<hidden> bud]$ ps -u bud

PID TTY TIME CMD

20444 ? 00:00:00 sshd

20445 pts/0 00:00:00 bash

20478 pts/0 00:00:00 ps

[bud@<hidden> bud]$

And then kill that PID ;)

BudMan you are TheMan!

Cheers so much, it works a treat :thumbsup:

Whey you kill -1, you are killing and restarting a process on your server (In this case the SSH Daemon (sshd) or ssh session process). Since the SSH session is actually a connection initiated by the SSH client, you have really no way of affecting what happens on that end, and that includes an auto restart of the session. As far as the client is concerned, when your process stops, it losses the connection and the remote user will see something like "Remote Server termintated connection" OR "Remote Connection lost".

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • The same guy who promised AGI in a year, and later he said: yes, but no really.
    • Microsoft and security. 🤣 One day, I received a big bill from Microsoft. I checked the log, and the log (not Azure Premium) only lasted a few weeks, so I was unable to find any information about what happened. I checked the bill, and it showed me that somebody (no information) created a big virtual machine for many weeks, then finally deleted it. I contacted support, and they told me that I will get my money back. 8 months later, it never happened. However, the invoices show some weird movements. They indeed did the reverse, but only in the system, but my CC never got the money back. I had a fight with my bank, and my bank finally showed me records that Microsoft never tried to return my money. What happened, who hacked it, and how? Microsoft was unable to answer. My account had a DFA. Conclusion: I should have reported it to my CC.
    • How predictable, didn't take long before the data-hungry devils at microsoft started offering the new web-based trash outlook as the solution to bugs they've added in Outlook Classic...
    • It's not just you, YouTube confirms missing navigation bar on Android by Aditya Tiwari The online video-sharing giant YouTube took to its community support forum to acknowledge a bug in its Android app that has been bothering users for some time. The said bug, which hides the app's bottom navigation bar, affects both free and premium users on the YouTube app for Android. In other words, affected users may not see the Subscriptions, Notifications, and Library navigation buttons at the bottom of the screen. "We're aware some of you are experiencing issues with the navigation bar for the YouTube App. This might also affect YouTube premium users," YouTube said. "Our teams are actively investigating this issue! We'll update this thread as soon as we have new information." The Google-owned platform is currently working to fix the issue and notes that the problem is affecting Android users living in the US. However, unverified user reports in the comments suggest that the issue has plagued other regions, including India, Germany, Poland, Spain, Nigeria, Australia, and others. Among various brands, there are several mentions from users running devices with Xiaomi's HyperOS software. Some users attempted to uninstall and reinstall the YouTube app, clear the cache, and roll back updates, but were unable to achieve success. It has been months since Android users have reported problems with the app's navigation bar, where it may disappear randomly and return after the app is restarted. With the navigation bar gone on the YouTube Android app, some users reported being unable to upload videos or access the profile button. It's hard to say whether YouTube was working to make it auto-disappear, and things went south. For now, all users can do is wait for a fix from the company. Speaking of new changes, a recent YouTube update has killed support for several older iPhone models. Google confirmed that it will bring more ads to the cheaper YouTube Lite plan.
  • Recent Achievements

    • Week One Done
      Adam Todd earned a badge
      Week One Done
    • Contributor
      Ed B went up a rank
      Contributor
    • One Month Later
      moporcho earned a badge
      One Month Later
    • One Month Later
      Parotel earned a badge
      One Month Later
    • Reacting Well
      Cryptecks earned a badge
      Reacting Well
  • Popular Contributors

    1. 1
      +primortal
      200
    2. 2
      snowy owl
      143
    3. 3
      ATLien_0
      133
    4. 4
      Xenon
      120
    5. 5
      +FloatingFatMan
      104
  • Tell a friend

    Love Neowin? Tell a friend!