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 my_account@some.netapp.lan
.
I have found it to be convenient and easy to create bash aliases for these systems. It’s simple to do:
1 |
alias na01="ssh -i ~/.ssh/na01.key andrew-nadm@na01.private.lan" |
Now, whenever I type na01 version
it will automatically expand the “na01
” to be the full command.
1 2 3 4 5 6 7 8 |
[Andrew@cent01 ~]$ na01 hostname na01 [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…
1 |
echo "alias na01='ssh -i ~/.ssh/na01.key andrew-nadm@na01.private.lan'" >> ~/.bashrc |
If you are feeling particularly fancy, you can configure SSH for autocomplete of the hostnames also.