There are several ways to handle this.
My favorite way is to install http://pamsshagentauth.sourceforge.net/ on remote systems, as well as your own public key. (Think about how to install them in a virtual machine, somehow you have the whole Unix system installed, what are a few more files?)
When forwarding your ssh agent, you can log in without a password.
And even better, the pam module will authenticate to sudo with your ssh key pair so that you can work with root privileges (or any other users) as needed.
You do not need to worry about interacting with the host key. If the input is not a terminal, then ssh will simply limit your ability to forward agents and authenticate passwords.
You should also look into packages like Capistrano. Definitely inspect this site; It has an introduction to the remote script.
Personal script lines might look something like this:
ssh remote-system-name command arguments ...
DigitalRoss Dec 18 '12 at 8:10 2012-12-18 08:10
source share