in reply to How to remotely execute a command that requires input?

Assuming you're using ssh, your best bet is to take advantage of the facilities it already has for doing this, such as setting up public key authentication.

Update: To clarify, ssh's authentication facilities will help run the remote script as the right user to begin with, replacing sudo; they won't help you simulate keyboard input to another script. For that, use ssh -t and Expect.