#!/bin/sh # # Select a ssh binary depending on the target host. # This is necessary in order to use sftp on some # kerberized remote hosts where the ssh binaries # must have special patches applied and where these # patches are either not available for recent ssh # implementations (forcing one to use an outdated one) # or where these patched ssh binaries behave badly # with NAT and LANs (reverse ip mapping lockups). # So the best solution is to have a flexible setup # that allows one to use different ssh clients -- # one for each target host if ever necessary... # # The format of /etc/ssh-chooser.conf is like: # # .fnal.gov /home/mark/div/local/ssh-krb5/bin/ssh # # etc. # # The default is to just use 'ssh'. The first entry # is matched against the tail of the host name, the # second entry is the ssh binary. # CFG="ssh-chooser.conf" TAILS="" CFGS="" [ -r "/etc/$CFG" ] && CFGS="$CFGS /etc/$CFG" [ -r "$HOME/.$CFG" ] && CFGS="$CFGS $HOME/.$CFG" TAILS=`awk '{ print $1 }' $CFGS` # # I'm not wasting time on finding out how the different # ssh implementations process their arguments in order # to find the target host name among all of them. We # just try to match against each one of them that does # not start with a '-'. # BINARY="ssh-default" for a in $* ; do [ "x$a" != "x${a#-}" ] && continue for t in $TAILS ; do [ "x$a" != "x${a%$t}" ] && BINARY=`awk "{ if ( \\$1 == \"$t\" ) { print \\$2 } }" $CFGS` done done exec "$BINARY" "$@"