SSH in for loop (consuming stdin / using file descriptor 3)

Ever found yourself using a for/while loop using SSH in the loop, only to find out your loop only runs once?

Your stdin is captured by ssh… This can be fixed.

while read -u 3 line
do
    command1
    command2
done 3< <(tail -f /path/file.txt)


OR


exec 3< <(tail -f /path/file.txt)

while read -u 3 line
do
    command1
    command2
done