Fix memory ownership of host key
Allow converting host key type to format needed for KnownHosts