aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rwxr-xr-xbin/portfwd-local.sh26
1 files changed, 26 insertions, 0 deletions
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 <aly@aaronly.me>
+# 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` <local_port> <dest_port> <host>"
+ exit 1
+fi
+
+LPORT="$1"
+DPORT="$2"
+HOST="$3"
+
+ssh -L ${LPORT}:localhost:${DPORT} ${HOST}