Clean up a lot how the ssh search is generated and maintained.

This commit is contained in:
2025-03-10 15:23:10 -04:00
parent 2e677b6325
commit a1dd3bd43c
3 changed files with 21 additions and 4 deletions

1
ssh/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
ssh-search-domains

19
ssh/gen-search.sh Executable file
View File

@ -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

View File

@ -3,10 +3,7 @@
# #
# That config uses Canonicalization to emulate what your local resolver # That config uses Canonicalization to emulate what your local resolver
# does in these circumstances. # does in these circumstances.
Match exec 'rm -f ~/ssh/search | false' Match exec "~/cshenv/ssh/gen-search.sh"
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'
Include ~/.ssh/search Include ~/.ssh/search
# vim: ft=sshconfig # vim: ft=sshconfig