SSH, REMOTE SCRIPT, ERROR MESSAGE
Try ssh -t -t to force pseudo-tty allocation even if stdin isn’t a terminal.
ssh -t -t