2

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)?
Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Nakilon
  • 144

3 Answers3

2

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

jirib
  • 1,168
1

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 ~]$
0

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.

ewwhite
  • 1,521