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

    • They need to get rid of the thousand that no one is buying.
    • The first generation of iPhones had Java 2 Mobile Edition (J2ME) support (ok ok JVM support) which was the same framework/version that Android and BlackBerry and PalmOS all ran on (in addition to their Linux roots) which increased the prospect of third-party developer integrations on the platform. The way in which Apple was able to veer in a different direction with their iOS (hint: native Objective-C) than how Android and BlackBerry evolved (hint: Java) is part of their engineering legacy. The performance hit is so pronounced that even Android is reengineered for Kotlin rather than traditional Java programming.
    • So I have a confession to make : I've used PCs mostly with Intel processors for over 30 years, I've been a developer for 12 years, chosen Intel PCs for my dev team at work, managed those PCs with MS Intune... And I still have no idea what "vPro" is or why I would need it.
    • XRECODE3 1.166 by Razvan Serea xrecode3 is a converter and audio-grabber which allows you to convert from mp3, mp2, wma, aiff, amr, ogg, flac, ape, cue, ac3, wv, mpc, mid, cue ,tta, tak, wav, wav(rf64), dts, m4a, m4b, mp4, ra, rm, aac, avi, mpg, vob, mkv, mka, flv, swf, mov, ofr, wmv, divx, m4v, spx, 3gp, 3g2, m2v, m4v, ts, m2ts, adts, shn, tak, xm, mod, s3m, it, mtm, umx, mlp to m4a, alac, ape, flac, mp3, mp4 (using NeroAAC), ogg, raw, wav, wav(rf64), wma, WavPack, mpc, mp2, Speex, ofr, ac3, aiff, tak, snd and Shorten formats. Command Line parameters are supported. XRECODE3 features: Works on XP, Vista, Windows 7, Windows 8, 10 32/64 bit versions and under Wine. Parallel conversion by utilizing power of multi-core CPUs. Support of embedded CUE sheets (for FLAC, WavPack, APE and TAK files). Support of mp4, mka chapters (can split mp4, mka by chapters to any supported format). Built-in Metadata editor with Cover Art support. Has support for LossyWav. Supports portable mode. Merge input files to one large audio file and create CUE sheet. Converting to many formats at once using "Multiple" output mode. Grabbing of multi-channel Audio CDs to the desired format at once. Informative and resizable UI suited even for netbooks. Extracting audio from flv, avi, mov etc. video files (multiple audio streams are supported). Can export/import Metadata to/from external file. Support for 24/32bit audio files. Multilanguage support. Currently program is available in Dutch, English, French, Japanese, Korean, Polish, Russian, Hungarian, Italian, Spanish, Spanish Traditional, Swedish, Brazilian Portuguese, German, Finnish, Bulgarian, Czech, Danish and Chinese (simplified) languages. What's new in XRECODE3: Native 64bit support. Added support for DSD/DST and DFF formats (including handling of SACD ISOs). Added option to extract audio without transcoding. Added option to encode several files to one multi-channel file. Added option to split file into individual track-per-channel for all available output formats. Added option to merge files per folder. Output and Metadata settings are now output format specific. Enhanced Metadata settings. Added support for multiple Cover pictures in Metadata editor. Added 32bit int/float output for formats which support them (e.g. WAV). Added dithering option in Output Settings. Added option to use EBUR128 in Normalize. Added option to Album Mode Normalize. Added option to configure Matrices under Output Settings. Added more output file pattern elements. Tabbed UI. CUE files are now displayed more nicely. Enhanced Shell Extension. XRECODE3 1.166 changelog: fixed crash when opening a file without an audio stream. fixed issue when applying tempo to some files. fixed issue with handling of some .ofr files. Download: XRECODE3 v1.166 (64-bit) | Portable | ~30.0 MB (Shareware) Download: XRECODE3 v1.166 (32-bit) | Portable Link: XRECODE3 Homepage | XRECODE3 Screenshot Get alerted to all of our Software updates on Twitter at @NeowinSoftware
  • Recent Achievements

    • One Year In
      Mido gaber earned a badge
      One Year In
    • One Year In
      Vladimir Migunov earned a badge
      One Year In
    • One Month Later
      daelos earned a badge
      One Month Later
    • Week One Done
      daelos earned a badge
      Week One Done
    • Mentor
      Karlston went up a rank
      Mentor
  • Popular Contributors

    1. 1
      +primortal
      494
    2. 2
      snowy owl
      252
    3. 3
      +FloatingFatMan
      250
    4. 4
      ATLien_0
      225
    5. 5
      +Edouard
      183
  • Tell a friend

    Love Neowin? Tell a friend!