Sign up ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

I have many servers and they all end with the same, so for example, and was wondering if it is possible to make it so i can just type the vded-xx-001 and have it append the automatically ?

So i would want to type

ssh user@vded-xx-001

and have it actually connect to


I have tried setting my DNS-search domain to, in /etc/network/interfaces, but this did not achieve the desired outcome.

Anyone able to point me in the right direction ?

Thanks in advance

share|improve this question
Is there any reason you can not just add search to /etc/resolv.conf ? –  Hennes Apr 16 '13 at 11:21
@Hennes Adding search and to resolv.conf has worked. However there is a warning at the top of the file that my changes will be overwritten, if this is the case how do i make them permanent ? –  Tim Lassie Freeborn Apr 16 '13 at 11:27
I would love to answer that and rake in the extra rep, but this post already answers that quite well: :-)… –  Hennes Apr 16 '13 at 11:35
Actually, contrary to what is discussed in that question, it's normally best to include a search domain list either in /etc/network/interfaces (using a dns-search option) or in the NetworkManager connection configuration field Search domains. –  jdthood Apr 19 '13 at 14:46

3 Answers 3

up vote 1 down vote accepted

The solution to my problem was to add the search domain to resolv.conf:


This has allowed me to enter

ssh user@vded-xx-001

for any of my servers and it connect to the correct address.

Thank you @Hennes for the answer

share|improve this answer
Assuming you are running Ubuntu 12.04 or later, you shouldn't edit /etc/resolv.conf directly because the resolvconf utility generates that file. (Actually it generates /run/resolvconf/resolv.conf to which /etc/resolv.conf is a symbolic link.) Instead you should configure DNS settings through the interface configurer, either ifup or NetworkManager. Ifup: Edit /etc/network/interfaces and add a dns-search line to the stanza for the machine's external network interface. NM: Add to the Search domains field on the IPv4 tab for the connection. –  jdthood Apr 19 '13 at 14:30
If /etc/resolv.conf is not a symbolic link to ../run/resolvconf/resolv.conf on your machine then run sudo dpkg-reconfigure resolvconf to restore the symbolic link. –  jdthood Apr 19 '13 at 14:31

Yes, you can do this by creating a config file named ~/.ssh/config and entering the following contents:

Host vded-xx-001
User user
Port 22

Now you just have to type this (you don't even need the username any more):

$ ssh vded-xx-001

This also works with the command-line utility scp:

$ scp filename vded-xx-001:/path/
share|improve this answer
I am aware that this works for individual hosts but i have hundreds and was hoping i could create a rule that picks up on VDED-* and then for the hostname does –  Tim Lassie Freeborn Apr 16 '13 at 11:24
@TimLassieFreeborn: you could write a script that generates the entries needed for the config file. I don't know if you can do it dynamically, though. –  Flimm Apr 16 '13 at 11:25

For a quick solution that works across different programs, you can also set the domain vded-xx-001 to redirect to a specific IP address, by editing /etc/hosts to include a line like this:  vded-xx-001

This works in your browser: http://vded-xx-001/

As well as with command-line utilities like SSH:

$ ssh user@vded-xx-001

(I personally prefer the SSH config solution though.)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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