#!/bin/bash # this will superceed the ssh binary in order to source all the config files module_load file # loads find and build_file function ssh_config () { local CDIRS local CDIR local DIRS local DIR local PDIRS declare OPTION declare OPTARG declare OPTIND while getopts 'd:' OPTION; do # echo $OPTION $OPTARG case "$OPTION" in d) PDIRS=$OPTARG # echo option d: $DIRS ;; *) echo unknown option $OPTION ;; esac done shift $(( OPTIND - 1 )) local OUTPUT=${*:-"$BASH_SHELL_BASE/ssh/config/_config"} [[ $PDIRS ]] && DIRS=($PDIRS) || DIRS=(${BASH_SHELL_DIRS} "$HOME/$BASH_SHELL_USER") # echo DIRS "${DIRS[@]}" # echo $OUTPUT CDIRS=() j=0 cnt=${#DIRS[@]} for ((i=0;i $OUTPUT build_file "/etc/ssh/ssh_config" $OUTPUT # echo existing dirs ${CDIRS[@]} for CDIR in "${CDIRS[@]}" do # FILES=$(find -n '*.cfg' -d 0 $CDIR) for f in $(find -n '*.cfg' -p 'archive off' -d 0 $CDIR) ; do # echo "Processing $f"; [[ $f ]] && build_file "$f" $OUTPUT done done build_file "$HOME/.ssh/config" $OUTPUT } ssh () { if [[ $1 = "-F" ]]; then CONFIG=${2:-"$BASH_SHELL_BASE/ssh/config/_config"} shift;shift fi CONFIG=${CONFIG:-"$BASH_SHELL_BASE/ssh/config/_config"} [[ -f "$CONFIG" ]] || ssh_config "$CONFIG" command ssh -F $CONFIG "$@" }