wok rev 20304

sshx: add port support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat May 05 17:00:11 2018 +0200 (2018-05-05)
parents 7431a9295130
children df2a96b56a0f
files dropbear/stuff/sshx
line diff
     1.1 --- a/dropbear/stuff/sshx	Fri May 04 15:44:38 2018 +0200
     1.2 +++ b/dropbear/stuff/sshx	Sat May 05 17:00:11 2018 +0200
     1.3 @@ -23,8 +23,8 @@
     1.4  	xhost +localhost > /dev/null 2>&1
     1.5  	pxypass="${DBPROXY_PASSWORD:+export DROPBEAR_PASSWORD=$DBPROXY_PASSWORD; }"
     1.6  	[ -n "$1" ] || set -- "${TERM:-xterm} -ls || ${TERM:-sakura} -l || xterm -ls"
     1.7 -	exec dbclient -f -R $((6000+$n)):localhost:$((6000+${svr%.*})) $r \
     1.8 -	   ${DBPROXY:+-J "sh -c '${pxypass}dbclient ${k}-B ${a#*@}:$p $DBPROXY'"} \
     1.9 +	exec dbclient -f -R $((6000+$n)):localhost:$((6000+${svr%.*})) ${r/:/ -p } \
    1.10 +	   ${DBPROXY:+-J "sh -c '${pxypass}dbclient ${k}-B ${a#*@}:$p ${DBPROXY/:/ -p }'"} \
    1.11  	   "xauth add $dpy $data; export DISPLAY=$scr; $@ ; xauth remove $dpy" \
    1.12  	   </dev/null >/dev/null
    1.13  }
    1.14 @@ -32,12 +32,13 @@
    1.15  pppssh()
    1.16  {
    1.17  	ssh="dbclient -y"
    1.18 -	$ssh $1 true || {
    1.19 +	$ssh ${1/:/ -p } true || {
    1.20  		[ -z "$DROPBEAR_PASSWORD" ] && echo -n "ssh password: " &&
    1.21  		read -s -t 30 DROPBEAR_PASSWORD && export DROPBEAR_PASSWORD
    1.22 -		$ssh $1 true || exit 1
    1.23 +		$ssh ${1/:/ -p } true || exit 1
    1.24  	}
    1.25 -	extra="$(route -n | awk -vd=$(nslookup ${1#*@} | sed '/::/d' | \
    1.26 +	ipsvr=${1#*@}; ipsvr=${ipsvr%:*}
    1.27 +	extra="$(route -n | awk -vd=$(nslookup $ipsvr | sed '/::/d' | \
    1.28  		 sed '$!d;s/.*: \([^ ]*\).*/\1/') \
    1.29  		'$1=="0.0.0.0"{ print d " gw " $2 " dev " $8 }')"
    1.30  	for i in ${4/default/128.0.0.0/1 0.0.0.0/1} ; do
    1.31 @@ -48,13 +49,13 @@
    1.32  	n=10.$(($$%256)).$(($$/256))
    1.33  	n="${2:-$n.1:$n.2} passive"
    1.34  	ppp="/usr/sbin/pppd local noauth nodetach"
    1.35 -	arg="$n pty '$ssh $1 $ppp ${3:-proxyarp} notty'"
    1.36 +	arg="$n pty '$ssh ${1/:/ -p } $ppp ${3:-proxyarp} notty'"
    1.37  	pppsvr="$ppp $n ${3:-proxyarp} notty >/dev/null"
    1.38  	sshcmd="nc -ulp $5 -e $pppsvr"
    1.39 -	udpcmd="nc -u ${1#*@} $5"
    1.40 +	udpcmd="nc -u $ipsvr $5"
    1.41  	[ "$6" == "test" ] && sshcmd="nc -ulp $5 -e nc localhost 22" &&
    1.42 -	udpcmd="dbclient -y -J \"nc -u ${1#*@} $5\" ${1%@*}@localhost $pppsvr"
    1.43 -	[ -n "$5" ] && arg="noipdefault pty '$udpcmd'" && $ssh -f $1 "$sshcmd"
    1.44 +	udpcmd="dbclient -y -J \"nc -u $ipsvr $5\" ${1%@*}@localhost $pppsvr"
    1.45 +	[ -n "$5" ] && arg="noipdefault pty '$udpcmd'" && $ssh -f ${1/:/ -p } "$sshcmd"
    1.46  	eval $ppp $arg ipparam pppssh$$
    1.47  	[ "$4" ] && route del $extra
    1.48  	rm -f /etc/ppp/ip-up.d/pppssh$$ 2> /dev/null
    1.49 @@ -65,8 +66,8 @@
    1.50  	p=5900
    1.51  	while netstat -tln | grep -q ":$p " ; do p=$(($p+1)); done
    1.52  	[ -r /dev/input/mice ] || echo "Warning: Cannot read mouse input." 1>&2
    1.53 -	svr=${1#*/}; [ "$svr" == "$1" ] && svr=127.0.0.1
    1.54 -	dbclient -y -f -N -L $p:$svr:${2:-5900} ${1%/*}
    1.55 +	r=${1%/*}; svr=${1#*/}; [ "$svr" == "$1" ] && svr=127.0.0.1
    1.56 +	dbclient -y -f -N -L $p:$svr:${2:-5900} ${r/:/ -p }
    1.57  	fbvnc 127.0.0.1 $p
    1.58  	kill $(netstat -tlnp 2> /dev/null | \
    1.59  	       sed "/:$p /!d;s|.* \\([0-9]*\\)/[^ ]*|\\1|")
    1.60 @@ -74,11 +75,11 @@
    1.61  
    1.62  case "$(basename $0)" in
    1.63  *vnc)	[ -z "$1" ] && cat <<EOT || xfbvnc "$@" ;;
    1.64 -Usage: $0 '[sshargs] user@remote[/lanip]' [vncport]
    1.65 +Usage: $0 '[sshargs] user@remote[:port][/lanip]' [vncport]
    1.66  $(fbvnc --help 2>&1 | sed '1,/Usage:/d')
    1.67  EOT
    1.68  ppp*)	[ -z "$1" ] && cat <<EOT || pppssh "$@" ;;
    1.69 -Usage: $0 '[sshargs] user@remote' '[localip:remoteip] [localpppargs]' 'remotepppargs' 'routes' [udp-port]
    1.70 +Usage: $0 '[sshargs] user@remote[:port]' '[localip:remoteip] [localpppargs]' 'remotepppargs' 'routes' [udp-port]
    1.71  Example: $0 tux@slitaz.org '' '' '192.168.1.0/24 10.1.2.0/24'
    1.72  EOT
    1.73  *)	[ -z "$DISPLAY" ] && exec dbclient -y "$@"