Issue #1240: Updated ensure_hostname_in_hosts to use SSH_CONNECTION with failover to hostname -i