Tuesday, April 1, 2014

No DNS search domain for SSH after Mavericks upgrade

I often access a lot of server via SSH that all resides on the same domain. So I have set up a the as a search domain. Since I am on OSX I have do do this via the Network preference GUI. To add a search domain edit the connection, hit the DNS tab and a  the domain you want to autocomplete from. This will add the search domain to your resolve.conf, that is automatically generated on OSX. If you are on other *NIX systems, just edit your resolve.conf and add

search example.org

This will, after reload, enable you to ssh to a host under the search domain without specifying the full hostname, ie.

$ ssh root@host

will try to connect  to host.example.org.

For some reason this does not work out of the box on OSX after the Lion release. And it was again broken after I upgraded to Mavericks. Apparently the search domain is not used. Thank to Google I found this which helped my resolve the problem.

To fix the problem edit /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist and add the following key

<string>-AlwaysAppendSearchDomains</string>

to the array under ProgramArguments. After a restart of the DNS service by doing

$ sudo launchctl unload -w System/Library/LaunchDaemons/com.apple.mDNSResponder.plist
$ sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.mDNSResponder.plist

SSH should complete hostnames from the search domain.