Issue #1240: Updated ensure_hostname_in_hosts to use SSH_CONNECTION

Hopefully these changes will provide a more consistent IP address choice?