From cd56141f5545a670887619166879fbecc466749c Mon Sep 17 00:00:00 2001 From: Aaron LI Date: Mon, 29 May 2017 10:39:56 +0800 Subject: Add bin/portfwd-local.sh: Local port forwarding using SSH --- bin/portfwd-local.sh | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 bin/portfwd-local.sh (limited to 'bin') diff --git a/bin/portfwd-local.sh b/bin/portfwd-local.sh new file mode 100755 index 0000000..7987228 --- /dev/null +++ b/bin/portfwd-local.sh @@ -0,0 +1,26 @@ +#!/bin/sh +# +# Copyright (c) 2017 Aaron LI +# MIT license +# +# Local port fowarding using SSH +# +# Credits: +# [1] https://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding +# [2] https://unix.stackexchange.com/a/115906 +# +# Aaron LI +# 2017-01-11 +# + +if [ $# -ne 3 ]; then + echo "Usage:" + echo " `basename $0` " + exit 1 +fi + +LPORT="$1" +DPORT="$2" +HOST="$3" + +ssh -L ${LPORT}:localhost:${DPORT} ${HOST} -- cgit v1.2.2