1 # $OpenBSD: dynamic-forward.sh,v 1.1 2003/06/26 14:23:10 markus Exp $
2 # Placed in the Public Domain.
4 tid="dynamic forwarding"
9 if [ -x `which nc` ] && nc -h 2>&1 | grep "x proxy address" >/dev/null; then
10 proxycmd="nc -x 127.0.0.1:$FWDPORT -X"
11 elif [ -x `which connect` ]; then
12 proxycmd="connect -S 127.0.0.1:$FWDPORT -"
14 echo "skipped (no suitable ProxyCommand found)"
17 trace "will use ProxyCommand $proxycmd"
23 for h in 127.0.0.1 localhost; do
24 trace "testing ssh protocol $p socks version $s host $h"
25 trace "start dynamic forwarding, fork to background"
26 ${SSH} -$p -F $OBJ/ssh_config -f -D $FWDPORT somehost sleep 10
28 trace "transfer over forwarded channel and check result"
29 ${SSH} -F $OBJ/ssh_config -o "ProxyCommand ${proxycmd}${s} $h $PORT" \
30 somehost cat /bin/ls > $OBJ/ls.copy
31 test -f $OBJ/ls.copy || fail "failed copy /bin/ls"
32 cmp /bin/ls $OBJ/ls.copy || fail "corrupted copy of /bin/ls"