Your clients will need at least one way to resolve the hostname to an IP address. The mechanism you already discovered works through automatic configuration and happens within the .local
domain name.
You could define the mapping from hostname to IP addresses on every client, but this is not recommended practice.
You will have to go through some kind of automatic name resolution mechanism, all of which require use of some kind of domain name in the background.
However, you can easily get rid of having to type the domain name each time by doing one of:
ssh hostname canonicalisation
If you put the following into /etc/ssh_config
or ~/.ssh/config
:
Host *
CanonicalDomains local
CanonicalizeHostname yes
ssh will automatically append local to any hostname. So when you type ssh host
it will actually do ssh host.local
.
search domains
While the above will work only for ssh, you can also configure a similar thing for all network connections by configuring the dns resolver on your client accordingly. It is the "classical" way of having hostname shortcuts.
Depending on which setup you have, you would add local
to the list of search domains. This is what I do. There should be plenty description for this available, like this.
hardcoding to /etc/hosts
This is not recommended at all, because although it seems simple in the beginning, it will become hard to maintain soon. But it is the only way known to me that allows to completely get rid of domain names.
Edit the file /etc/hosts
and add lines like this:
192.168.1.3 host3
192.168.1.4 host4
While the first word in each line is the IP address of the corresponding host. You have to do that on every client. After that you can use ssh host3
, and not even in the background a domain name will be used.