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.

1 comment:

markham said...

Apple used to have it together and made stuff that "just worked" and did the right thing. It seems that their success in the last few years has gone to their heads and stuff like this is popping up more and more often. Apple is no longer doing just the right thing, and useful features are becoming more and more obfuscated or just out right removed for no good reason. I think if Apple doesn't pull their collective swollen head out of whatever dank orifice it seems to be firmly shoved up, they are going to miss the writing on the wall!