Otherwise it inherits our streams, and something waiting from EOF from
us will become seriously disappointed. It's not like the master has
anything especially interesting to say on stdout anyway. The error
stream is captured into a logfile for later perusal.
Just stdout wasn't enough.
### Configuration.
: ${REAL_SSH=/usr/bin/ssh}
### Configuration.
: ${REAL_SSH=/usr/bin/ssh}
+: ${SSH_HOME=$(unset HOME; bash -c 'echo ~/.ssh')}
+: ${SSH_LOGDIR=$SSH_HOME/log-$(hostname)}
###--------------------------------------------------------------------------
### Parse the command line and dredge out information.
###--------------------------------------------------------------------------
### Parse the command line and dredge out information.
+ ## Catch the port number. We want this for building the logfile
+ ## name.
+ ?,p*)
+ masteropts=("${masteropts[@]}" "-p$arg")
+ port=$arg
+ ;;
+
## These options are interesting to the master connection.
m,[aADLlRSwxXv]*)
masteropts=("${masteropts[@]}" "-${o:0:1}$arg")
## These options are interesting to the master connection.
m,[aADLlRSwxXv]*)
masteropts=("${masteropts[@]}" "-${o:0:1}$arg")
exec "$REAL_SSH" "${opts[@]}" ${host+"$host"} "$@"
;;
m)
exec "$REAL_SSH" "${opts[@]}" ${host+"$host"} "$@"
;;
m)
+ mkdir -p -m700 "$SSH_LOGDIR"
+ logfile=$SSH_LOGDIR/${login+"$login@"}"$host"${port+":$port"}.log
if ! "$REAL_SSH" -Ocheck ${login+"$login@"}"$host" >/dev/null 2>&1; then
if ! "$REAL_SSH" -Ocheck ${login+"$login@"}"$host" >/dev/null 2>&1; then
- "$REAL_SSH" -MNf "${masteropts[@]}" "$host"
+ "$REAL_SSH" -MNf "${masteropts[@]}" "$host" \
+ </dev/null >/dev/null 2>$logfile
fi
exec "$REAL_SSH" ${opts[@]} "$host" "$@"
;;
fi
exec "$REAL_SSH" ${opts[@]} "$host" "$@"
;;