To autocomplete ssh hostnames from knownhosts,
complete -W "$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\["`;)" ssh
Source link
http://hints.macworld.com/article.php?story=20080317085050719
Advertisements