Proposal: adding support for port numbers to known_hosts handling (to fix hanging git operations)

Good day!

I came across a problem cloning a git repository using a SSH URL containing a different port number. e.g. ssh://git@example.domain:7999/path/to/repo.git

The problem I was getting was that there was also an SSH server running on the normal port (22) and the host key was been scanned and written based on that port rather than the port specified in the URL. This caused the git operations to hang waiting for the host key to be accepted.

The code change was a relatively simple one; you can view it here:

https://github.com/bentimms/ansible/commit/07c71ebe6cd9c607eceb1add038601cf45ee45e5

I branched from v1_last to make the change, but I think it should apply cleanly to master. I couldn’t see any unit tests around this code.

Let me know whether you feel this is a worthwhile change or have any comments or suggestions about the implementation.

Thanks!
Ben

looks fine to me