I’d like to be able to run ssh 142
(for example) from a bash prompt and have it automatically expand to ssh 10.33.7.142
. I’m thinking I should be able to do this from .bashrc, but I can’t figure out how to detect if a command-line argument is a single octet, and if so, automatically add a subnet before it.
I’d like to implement this on my CentOS LXC host nodes. The vast majority of the time when ssh is used on them it is to connect to a container running on them, all of which are in the same subnet.
Thank you.
2
Answers
In
~/.ssh/config
or/etc/ssh/ssh_config
:Now you can run :
To generate the config file :
You could write a function in your .bashrc like this: