Since you are only connecting to a single machine, use ssh directly. (only one machine listed after -w argument)
Code:
ssh root@machine 'passwd root'
It would be better to log into the machine as your regular user. and then su'ed to root. Changing the root password could lock you out, so it may not be a task to automate. Changing passwords, or editing sshd_conf, or changing rsa/dsa keys, you want to keep your original session open, and try logging in on a second session to test your changes.
As an aside, you might want to look at using cf engine to centrally manage 50 hosts.