Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When I connect to the company OpenVPN they don't push their DNS to my computer, which means I have to type the FQDN for the hosts I e.g. SSH and HTTP to.

Question

Is it possible to configure my Linux desktop, so can do

ssh ss@serv

instead of

ssh ss@serv.example.com

?

There is only one domain, so incase the non-FQDN fails, it will always work, if just example.com is appended.

share|improve this question

migrated from serverfault.com Jun 18 '13 at 13:58

This question came from our site for system and network administrators.

6  
linux.die.net/man/5/resolv.conf –  Iain Jun 18 '13 at 10:25

2 Answers 2

up vote 5 down vote accepted

Add this line to your resolv.conf:

search example.com

See resolv.conf(5) for details. If there is already a search line, just append example.com to its end

share|improve this answer

Another approach (~/.ssh/config):

Host *.example.com
 HostName %h
 USER user

Host *
 HostName %h.example.com
 USER user

This allows both forms:

ssh private.example.com # ssh user@private.example.com
ssh private             # ssh uesr@private.example.com

This really only works in the case where you are only connecting to .example.com hostnames (since * will match everything). I use a variation where I want to match only hostnames starting with dev-:

Host dev-*.example.com
 HostName %h
 USER user

Host dev-*
 HostName %h.example.com
 USER user
share|improve this answer

Your Answer

 
discard

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.