Marc Goldberg's Blog
Bash hostname completion in OS X

If you use Darwin Ports to get various open source utilities on your Mac, make sure to add bash-completion to your must-have list.  It configures programmable command-line parameter completion in much the same way tab-file-completion works.

It’s useful immediately out of the box in many ways, the most significant of which for me is the ssh/scp/etc hostname completion.  Any hostname that’s in your ~/.ssh/known_hosts file can be tab completed.

port install bash-completion
echo ". /opt/local/etc/bash_completion >> ~/.profile"

That’s it!