Bash: Limit runtime of a process

TIL that timeout exists.

You can simply prefix a command with a max runtime and it will be killed after the time runs out, e.g.: timeout 30m ssh tunnelhost -f -n -M -L 80:somehost:80