Skip to content

Instantly share code, notes, and snippets.

@shmick
Last active July 7, 2022 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shmick/7d635a8579647a789d7ffdfcc9d09506 to your computer and use it in GitHub Desktop.
Save shmick/7d635a8579647a789d7ffdfcc9d09506 to your computer and use it in GitHub Desktop.
A quick and dirty script to kill off stale ssh sessions on an asus router
#!/bin/sh
# add to cron to run every 20 minutes
# cru a ssh-clean "1,21,41 * * * * /jffs/cron/ssh-clean"
# remove cron
# cru d ssh-clean
netstat -p | grep ":ssh.*192.168.118.10:.*ESTABLISHED" | awk '{print $7}' | awk -F'/' '{print "kill", $1}' | sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment