Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

executable file 47 lines (33 sloc) 0.918 kb
#!/bin/sh
# Auto SSH Reverse Tunnel script, by Tomas Pollak
# ./tunnel.sh [host] [local_port] [remote_port] [user] [pass]
# lib/tunnel.sh proxy.preyproject.com 5900 6100 tunnel asdasd
# trap cleanup_tunnel EXIT
cwd=`pwd`
cleanup_tunnel(){
rm -Rf "$askfile" 2> /dev/null
}
create_askfile(){
askfile="$cwd/ssh_askpass"
cat > "$askfile" << END
#!/bin/sh
echo $1
END
chmod 700 "$askfile"
}
if [ -n "$5" ]; then # using password-based authentication
create_askfile "$5"
export SSH_ASKPASS="$askfile"
export SSH_TTY=/dev/null
# export DISPLAY=none:0.0
# eval `ssh-agent` >/dev/null
ssh-add < /dev/null
fi
# echo " -- Connecting to $host_port..."
ssh -N -o 'ExitOnForwardFailure=yes' -o 'StrictHostKeyChecking=no' -o 'CheckHostIP=no' -R ${3}:localhost:${2} ${4}@${1} &
tunnel_pid=$!
sleep 4
if [ "`ps -p $tunnel_pid | grep $tunnel_pid`" ]; then
echo "$tunnel_pid" > "prey-tunnel.pid"
fi
cleanup_tunnel
Jump to Line
Something went wrong with that request. Please try again.