When I do "ssh pru[TAB]", ssh completes to a non-resolvable hostname
from the .ssh/known_hosts file: prunille.vinc17.org
In fact this machine is resolvable only from my local network, and
it is an error to assume that a host key in .ssh/known_hosts is
necessarily resolvable (it may be there just to check the key thanks
to a HostKeyAlias declaration). IMHO, if the key is listed as an alias
from .ssh/config but not as a Host identifier, it should be discarded.
Hosts from .ssh/config should be used instead. The algorithm would be:
1. Take all host identifiers after Host declarations from .ssh/config
(strings with '?' and/or '*' should not be taken into account).
2. Add all hosts from .ssh/known_hosts that are not an argument of
a HostKeyAlias declaration (if hosts are in fact hashes, due to
HashKnownHosts, they should not be taken into account).
For instance, if .ssh/config has:
Host myhost
HostKeyAlias my-real-host-name.mydomain
Hostname gateway.mydomain
Port 12345
then "ssh my[TAB]" should complete to myhost only.
Of course, as a workaround to the current behavior, the user could
write:
Host myhost my-real-host-name.mydomain
HostKeyAlias my-real-host-name.mydomain
Hostname gateway.mydomain
Port 12345
but this can make maintenance of the config file less easy.