I have an SSH access to a lot of servers. And all that hostnames (and sometimes usernames) are long and hard to remember. Also even if I tweak my Terminal to keep eternal bash history, the using of history | grep ssh every time doesn't seem to be cool.

  1. How to config my bash or ssh to store user/host to be usable via something like autocomplete?
  2. Is there any recommendation specific to Mac OS X (Snow Leopard)?

man ssh_config, check 'Host' and 'HostName'. You can define your aliases with this.

  1. Possible duplicate of Bash Auto-Completion feature for SSHing into Different Hosts - with answers for Bash and ZSH shells, or another answer for Bash shell here: http://yourlinuxguy.com/?p=248

  2. I don't know of any specific one, but product recommendation questions are off-topic. https://serverfault.com/help/on-topic

  • Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. – EEAA Oct 9 '13 at 18:28
  • 1
    @EEAA, wouldn't the the preferable solution really be to migrate and mark this is as duplicate? – Zoredache Oct 9 '13 at 18:29
  • @Zoredache - yes, absolutely. – EEAA Oct 9 '13 at 20:03

This is completely a case for the bash-completion package. For Mac OS, the best way to install is to try Macports, Brew or a similar framework.


On most of my servers, I have set up key-exchange based password less ssh access.

In my .bashrc I simply define this kind of aliases:

alias ve='echo "Jumping to verylongname"; ssh verylongname'
alias ver='echo "Jumping as root to verylongname"; ssh root@verylongname'

This works like a charm - it is some 2 dozen machines and with only 2 letters mnemonic of the long name I get in instantly.

$ ve
Jumping to verylongname
Welcome to verylongname
[davidr@verylongname ~]$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.