TransWikia.com

How do I force-close all active ssh sessions that were started by a specific sshd daemon?

Unix & Linux Asked on December 8, 2021

I have a system that runs multiple sshd daemons. Each daemon listens to a separate port.

How can I terminate all sessions started by a specific daemon without affecting other ssh sessions?

3 Answers

if you have the pid of the sshd,

pkill --parent pid

should send SIGTERM to all children of the sshd

maybe add --signal kill if you want to force-kill them

Answered by hanshenrik on December 8, 2021

Run this to find out which PIDs you're interested in.

netstat -n -eep | grep port_number

Run any of these commands to see the interesting processes children and terminate them:

ps fax
# or
pstree -p

Answered by Artem S. Tashkinov on December 8, 2021

If you know the ssh port, you can simply kill all current tcp sessions that were initiated through it:

ss -K dport 22 

This kills all active ssh sessions that were started through port 22 while leaving other ssh sessions intact. Don't forget to stop the sshd daemon before you kill off its sessions.

Answered by Tenders McChiken on December 8, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP