When connecting to a host via SSH, I'd like to be able to simply type ssh hostname
to connect.
However, the setup we have currently means that I must type a fairly long suffix to connect, similar to hostname.hosts.companyname.com
.
Is it possible to set up SSH to cycle through several hostnames before giving up a connection without adding them to my hosts file? For example. if I type in
ssh hostname
, I would like SSH to:
- Attempt to SSH to
hostname
, if that fails after a short timeout: - Attempt to SSH to
hostname.hosts.companyname.com
, if that fails after a short timeout: - Attempt to SSH to
hostname.companyname.com
, and if that fails then it should print the error.
However, we have >1000 hosts and I would rather not add an alias to everything. I would prefer this to be default behaviour.
The above is a short example. I would prefer the ability to add something in the range of 30 potential domains to this list, which is why resolv.conf
search
is not an option (as it's limited to 6 domains).
host foobar
inside the network of my university faculty it will findfoobar.my-faculty.my-university.de
(assuming that host name exists). Alternatively you set up host name aliases in the SSH client configuration. – David Foerster Dec 17 '17 at 22:57/etc/resolv.conf
regarding search domain(s) ? That could fix it for you... – ivanivan Dec 18 '17 at 0:24known_hosts
locally and a base autocompletion system uses that file, meaning that if you dossh hostname[TAB][TAB]
will show you options, without having to define specifically each host. – Patrick Mevzek Dec 19 '17 at 1:40