Last Updated: February 25, 2016
·
1.335K
· arjones

Autocomplete SSH SCP and SFTP

Don't ever again type whole hostname to connect to remote servers.
Just add this snippet to your ~/.bashrc

# Add tab completion for SSH hostnames based on ~/.ssh/known_hosts
[ -e "$HOME/.ssh/known_hosts" ] && complete -o "default" -o "nospace" -W "$(cut -f1 -d','  \
  $HOME/.ssh/known_hosts | cut -f1 -d' ')" scp sftp ssh