Convert underscores in hostnames

Substitute underscores in names for hyphens when setting hostnames. These
aren't legally valid and some OSs, such as Debian 6, will outright refuse.

Keeping the names in the hash as underscores for compatbility with existing
users and so that they don't have to be modified from symbols.