This is how I do
in .basrhc
[distro defaults]
source ~/.bashrc_custom # only relevant to this host
source ~/.bashrc_common # useful to have on any machine
# sync this to any host I manage.
in ~/.bashrc_custom
[host relevant config]
source ~/.bash_lib/net.host
in ~/.bash_lib/net.host
#-*- shell-script -*-
# /\ /\
# |`\\_,--="=--,_//`|
# \ ." :'. .': ". /
# ==) _ : ' : _ (==
# |>/O\ _ /O\<|
# | \-"~` _ `~"-/ |
# >|`===. \_/ .===`|<
# .-"-. \===' | '===/ .-"-.
# .---{'. '`}---\, .-'-. ,/---{.'. '}---.
# ) `"---"` `~-===-~` `"---"` (
# ( Infra système )
# ) (
# '---------------------------------------'
alias net.host.ad.principal.rdp='krdc rdp://a.chaouche@192.168.100.21'
alias net.host.dns.rdp='krdc rdp://administrateur@10.10.10.4'
alias net.host.dns.ssh='ssh root@10.10.10.7 -p <port>'
[...]
# /\ /\
# |`\\_,--="=--,_//`|
# \ ." :'. .': ". /
# ==) _ : ' : _ (==
# |>/O\ _ /O\<|
# | \-"~` _ `~"-/ |
# >|`===. \_/ .===`|<
# .-"-. \===' | '===/ .-"-.
# .---{'. '`}---\, .-'-. ,/---{.'. '}---.
# ) `"---"` `~-===-~` `"---"` (
# ( Infra web )
# ) (
# '---------------------------------------'
alias net.host.appsrv.ssh='ssh root@10.10.10.83 -p 22022'
alias net.host.cloud.ssh='ssh root@cloud.algerian-radio.dz'
# /\ /\
# |`\\_,--="=--,_//`|
# \ ." :'. .': ". /
# ==) _ : ' : _ (==
# |>/O\ _ /O\<|
# | \-"~` _ `~"-/ |
# >|`===. \_/ .===`|<
# .-"-. \===' | '===/ .-"-.
# .---{'. '`}---\, .-'-. ,/---{.'. '}---.
# ) `"---"` `~-===-~` `"---"` (
# ( Infra messagerie )
# ) (
# '---------------------------------------'
alias net.host.messagerie.backup.ssh='ssh -lroot 192.168.100.25 -p 44044'
alias net.host.messagerie.prep.ssh='ssh root@192.168.100.19 -p 44044'
alias net.host.messagerie.secours.ssh='ssh root@10.10.10.20 -p 44044'
[...]
[... plus other sections ...]
On the command line, I can do
$ net.host.bandit.ssh
this will connect to bandit.labs.overthewire.org
changing the destination of this is as easy as editing my .bash_lib/net.host file
I can also do :
$ net.host.ksc.rdp
to rdp to 192.168.100.12 as user a.chaouche
etc.
You can think of any command you like.
The general template is
alias net.host.<host>.<command>='<command> <host address specification>'
Another approach would be to store the host address specifications as global env variables as suggested by christopher.
I do this for files and directories I like to cd to.
For example :
~ $ cd $MAIL_<tab>
$MAIL_LASTPASS $MAIL_NEWUSERS $MAIL_ROUNDCUBEFOLDER $MAIL_SCRIPTS
~ $ cd $MAIL_SCRIPTS
/usr/local/scripts/mail $ ls.count
219
/usr/local/scripts/mail $ type ls.count
ls.count is a function
ls.count ()
{
set -- $1*;
echo $$
}
/usr/local/scripts/mail $
So you can have the same type of variables to use for hosts
ssh $HOST_MAIL
nmap $HOST_WEBSERVER
ping $HOST_SVNSERVER