Skip to content

Instantly share code, notes, and snippets.

@lidel
Last active October 11, 2016 17:20
Show Gist options
  • Save lidel/88e2dffb7b85a30ce2742a66ea42ad5a to your computer and use it in GitHub Desktop.
Save lidel/88e2dffb7b85a30ce2742a66ea42ad5a to your computer and use it in GitHub Desktop.
Simple watchdog for local Tor Hidden Service
#!/bin/bash
# fail early, be verbose
set -o errexit -o nounset -o xtrace
# confirm the service on port 22 is routable, bounce tor node if no success in 10 seconds
nc.openbsd -v -z -w 10 -x 127.0.0.1:9050 $(cat /var/lib/tor/hidden_service/hostname) 22 || (service tor restart; exit 1)
# run health check every hour (send email only on errors)
42 * * * * chronic hidden-service-watchdog.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment