The -S (stdin) option causes sudo to read the password from the standard input instead of the terminal device. The password must be followed by a newline character.
The following commands pipes the passwords to the sudo command which takes the password from stdin.
ssh [email protected] 'echo <password> | sudo -S reboot now'