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?


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
| improve this answer | |

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.

| improve this answer | |

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.