When I try to connect to my Ubuntu device with the ssh terminal command, I have to add .local suffix to Ubuntu hostname. For example, if I want to ssh to my device with its hostname, my ssh command must have the .local suffix and command has the following format:

ssh username@device_hostname.local 

I'm aware that the .local suffix was appended by avahi (zeroconf) Linux service, but is there any quick (easy) way to bypass it? I want to be able to "ssh" my device only by its hostname without .local suffix at the end of the command, like this:

ssh username@device_hostname

What exactly I want to achieve is to completely remove the .local suffix from host name. I've read about running my private DNS server, but I would like to know if there is a less complex solution.

  • 3
    A host alias may be what you are looking for: askubuntu.com/questions/257472/host-alias-for-ssh – Takkat Apr 18 '18 at 12:47
  • 3
    Possible duplicate of Host alias for ssh – Takkat Apr 20 '18 at 9:40
  • @Takkat Thank you for your answer, but I think that isn't what I'm looking for. Using aliases are solid solution, but communication is still established over .local domain in a background process. What I really want is completely exclude .local from host name. I've read about running my private DNS server, but I'm curious is there any little less complex solution? – Boixos Noi Apr 20 '18 at 13:11
  • 1
    Is this on a Desktop or a Server install? Have you taken a look at your network configuration to see the search domains set up by your system for the default 'query' domain which is necessary for proper handling of local domain lookups? – Thomas Ward Apr 20 '18 at 13:52

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: host3 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.


In /etc/hostname is the name you want to update. For example mydomiain.com and I'm assuming you have root access. The command hostname can also be used. So you'll need to update the file with vi. Whatever is in line 1 needs to be updated with your domain name. Pretty simple.

  • This doesn't achieve what OP describes in the last paragraph. -1 – David Foerster Apr 21 '18 at 22:40
  • What do you mean? I have my hostname and connect without any extension of dot local. I use putty. I'm not sure why he's having issues. I'm just trying to assist – Webmaster TheCMG Apr 21 '18 at 22:44
  • In Ubuntu version of UNIX... This is the answer. Sounds like he isn't using Ubuntu – Webmaster TheCMG Apr 21 '18 at 22:46
  • Sorry, what I mean is actually in OP's comment. It looks like they're looking to get rid of the .local domain suffix entirely for all hosts in that domain through a suitable networking or DNS client configuration change. – David Foerster Apr 21 '18 at 22:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.