Allow run the pre-connect hook before the first SSH command is executed, but only run the locking in `with_lock` blocks.