My last post explained how to set up SSH key based authentication for connecting to a NetApp. If you have multiple/many systems to administer this makes it easy to quickly connect to and execute commands against your systems.
However, I’m lazy. I don’t want to type
ssh some_system_name or
ssh some.ip.add.ress for every system. Also, on some of my systems I have to specify the private key and username to use for connecting, which further lengthens the amount of typing I have to do:
ssh -i ~/.ssh/some_special_id firstname.lastname@example.org.
I have found it to be convenient and easy to create bash aliases for these systems. It’s simple to do:
alias na01="ssh -i ~/.ssh/na01.key email@example.com"
Now, whenever I type
na01 version it will automatically expand the “
na01” to be the full command.
[Andrew@cent01 ~]$ na01 hostname
[Andrew@cent01 ~]$ na01 version
NetApp Release 7.3.6: Thu Jul 7 00:41:19 PDT 2011
[Andrew@cent01 ~]$ na01 uptime
2:50am up 1:43 144 NFS ops, 0 CIFS ops, 0 HTTP ops, 0 FCP ops, 0 iSCSI ops
[Andrew@cent01 ~]$ na01 date
Sat May 4 02:50:06 GMT 2013
To make the alias permanent, add it to
.bashrc file in your home directory…
echo "alias na01='ssh -i ~/.ssh/na01.key firstname.lastname@example.org'" >> ~/.bashrc
If you are feeling particularly fancy, you can configure SSH for autocomplete of the hostnames also.