ed is the standard text editor
ed has one very strong advantage over other editors: it is scriptable. No, not scriptable as in you can write code to modify how it works, scriptable as in it can be driven by a file full of commands, and thus can be run remotely, in a loop. So, if you need to edit a file on a mess of machines, to make the same change everywhere, remember, "ed is the standard text editor."
Create a script file containing the ed commands and the appropriate text:
$ cat /tmp/edit
Then, use ssh to connect to the remote host and run the ed command on the file to be edited, reading standard input from the file. Trust me, using the separate file is easier than writing the commands in a here-document or something.
$ for j in 01 02; do for k in b c; do ssh host$k$j ed /usr/local/httpd/conf/httpd.conf < /tmp/edit; done; done