Bash autocompletion for ssh and scp

Bash autocompletion is really something you can get used to very quick if *nix is part of you daily routine. It comes with a ton of auto complete features, but one of them really stands out. It’s ssh and scp autocomplete, where scp goes one step further. When using scp with autocomplete it will not only complete the hostname you are about to copy files from, but it will also login in the background and autocomplete directories and files on the remote host. This last function will only work when using ssh key based login.

sudo apt-get install bash-completion

When on Ubuntu don’t forget to turn of hashed hostnames in the ssh known_hosts file by creating or editing ‘~/.ssh/config’.

HashKnownHosts no

I stumbled upon this by accident, and using it since then. Hope you enjoy it as much as I do!