Why does HostKeyVerification verifyHost receive host string in the form []:?

The SSH hosts file uses the syntax  [<host>]:<port> for hosts where the SSH server resides on a non-standard port. This is to differentiate it from other SSH servers running on the same host. We pass the value to your HostKeyVerification that would normally be written directly to the known_hosts file.

Your implementation should be aware of this, multiple servers on the same host are likely to have different host keys. So you should process this format to avoid confusion.

If you don't want to receive this format of host you can disable it by setting the system property:


Have more questions? Submit a request


Please sign in to leave a comment.