The problem is that ssh
reads from standard input, therefore it eats all your remaining lines. You can just connect its standard input to nowhere:
ssh $USER@$SERVER "cd ${REMOTE_PATH}; mkdir -p $i" < /dev/null
You can also use ssh -n
instead of the redirection.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…