SSH port forwarding bypass Firewall (tunneling)

ssh -f -L {local-port}:localhost:{remote-server-port} user@remote.server.com

#The following example tunnels port 3001 session from client machine 127.0.0.1 (localhost) to remote server called "server.node"
ssh -f -L 3001:localhost:3001 user@server.node
#The connection is forwarded to port 3001 on the remote server. If 3001 is web based app, open a web browser and type the url http://localhost:3001/


You can also create a script as follows (open.3001):
$ vi ~/open.3001

#Append following code:
#!/bin/bash
ME="$(basename $0)"
SSHUSER=username
SERVER=remote.example.com
[ $ME == "open.3001" ] && ssh -N -f -L 3001:localhost:3001 ${SSHUSER}@${SERVER} || :
[ $ME == "open.10000" ] && ssh -N -f -L 10000:localhost:10000 ${SSHUSER}@${SERVER} || :
[ $ME == "open.3000" ] && ssh -N -f -L 3000:localhost:3000 ${SSHUSER}@${SERVER} || :

# Set permissions, enter:
$ chmod +x ~/open.3001

# Create soft-link, enter:
$ ln -s ~/open.3001 ~/open.10000
$ ln -s ~/open.3001 ~/open.3000

Comments