I need a way to log into a list of hostname/IPs as a user, su to root and then create/append root's .bashrc
root doesn't have permission to ssh directly into the server
ssh hostname "sudo -S sh -c 'echo stuff >> /root/foo.txt'" < password.txt
You'll still need to type in each ssh password, but it will read the sudo password from password.txt.
Hope this helps.
As mentioned in godswearhats' comment, sudo -S will probably be useful. Hopefully you have ssh public keys already in place to remove the ssh login prompts. If not I'd recommend pushing them over before the commands. Same number of credential prompts (one for each machine initially, none on the actual change commands), and you're set for no prompts at that level next time.
I'd recommend strongly considering setting up something like Puppet. Like ssh keys, onfiguring that may have the same amount of pain as the actual config push, you can then do the config push with little additional work, and you're set for next time.