aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorAaron LI <aly@aaronly.me>2017-05-29 10:39:56 +0800
committerAaron LI <aly@aaronly.me>2017-05-29 10:39:56 +0800
commitcd56141f5545a670887619166879fbecc466749c (patch)
treeb75d1ddac3b5ffae55aa285a5dda86d554293df6 /bin
parent0a8e96145bfa3aac3aeb1a013f07e88c7a6db1b8 (diff)
downloadatoolbox-cd56141f5545a670887619166879fbecc466749c.tar.bz2
Add bin/portfwd-local.sh: Local port forwarding using SSH
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}