When I dealt with a similar issue, my solution was to not run the SSH command with -N, but instead send the command bash -c 'echo "Connected" && while true ; do sleep 1; done'. Once connected, it would write "Connected" to STDOUT and then sleep forever; my outer script could just watch SSH's STDOUT for that string (or, indeed, any string).