diff --git a/ssh/.gitignore b/ssh/.gitignore new file mode 100644 index 0000000..98b4fd5 --- /dev/null +++ b/ssh/.gitignore @@ -0,0 +1 @@ +ssh-search-domains diff --git a/ssh/gen-search.sh b/ssh/gen-search.sh new file mode 100755 index 0000000..8a66c2c --- /dev/null +++ b/ssh/gen-search.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +rm -f ~/.ssh/search + +if [ -e ${CSHENV_DIR}/ssh/ssh-search-domains ] +then + domains=`grep "^search" /etc/resolv.conf | cut -c 6- - | cat - ${CSHENV_DIR}/ssh/ssh-search-domains | xargs` +else + domains=`grep "^search" /etc/resolv.conf | cut -c 6- - | xargs` +fi + +if [ -z "${domains}" ] ; then exit 1; fi +echo ${domains} + +printf "Host *\n\tCanonicalDomains ${domains}\n\tCanonicalizeHostname yes\n# v" > ~/.ssh/search +printf "im:ft=sshconfig" >> ~/.ssh/search + +exit 0 + + # vim: ft=bash diff --git a/ssh/prologue b/ssh/prologue index 72afa6d..0dac0ad 100644 --- a/ssh/prologue +++ b/ssh/prologue @@ -3,10 +3,7 @@ # # That config uses Canonicalization to emulate what your local resolver # does in these circumstances. -Match exec 'rm -f ~/ssh/search | false' - -Match exec 'grep "^search" /etc/resolv.conf ' exec 'grep search /etc/resolv.conf | awk \'{print "Host *\n\tCanonicalDomains "$2"\n\tCanonicalizeHostname yes\n# v""im:ft=sshconfig"}\' > ~/.ssh/search' - +Match exec "~/cshenv/ssh/gen-search.sh" Include ~/.ssh/search # vim: ft=sshconfig