#!/bin/sh

if [ $# -eq 0 ]; then
    echo "Usage: $0 username@machine destination-port [local-port]"
    exit 1
fi

destination=$1
destinationport=$2

if [ $# -eq 2 ]; then
    localport=$destinationport
else
    localport=$3
fi

ssh -q -N -L ${localport}:localhost:${destinationport} $destination