aboutsummaryrefslogtreecommitdiffstats
path: root/bin/portfwd-local.sh
blob: 79872284e4f41f29a50c61bf62b1b7d3fc61ee83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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}