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.
Showing posts with label SSH. Show all posts
Showing posts with label SSH. Show all posts
Tuesday, April 1, 2014
Wednesday, September 7, 2011
Sticky session on Linux
Today i stumbled upon the slides from a talk given at Confoo 2011 by Sean Coates called "Fifty Tips, Tricks and Tools ...in one talk". Most of the stuff was not new to me, but still informative. But slide 56 gave a very usefull snippet "Sticky shell start", which allows you to login and be placed where the last shell operated.
You should place the following snippit in your
To me this is very usefull since i often jump between different servers and often need to go to the same place every time. so this saves me a lot of typing.
You should place the following snippit in your
~/.bashrc or ~/.profile
cd () { builtin cd "$@" ; pwd > ~/.pwd ; }cd "`cat ~/.pwd`" To me this is very usefull since i often jump between different servers and often need to go to the same place every time. so this saves me a lot of typing.
Subscribe to:
Posts (Atom)