User Tools

This is an old revision of the document!


On Local Host

Create a new user called tunnel. Leave tunnel home folder on root partition (/home/tunnel) to avoid tunnel failure if partitions don't mount. You need also to create an SSH key, and prepare the tunnels config folder /home/tunnel/tunnels and log folder /home/tunnel/logs:

 > useradd -m tunnel
 > su - tunnel
 > ssh-keygen
 > mkdir tunnels
 > mkdir logs

Add tunnels configurations like this under /home/tunnel/tunnels/main:

main
REMOTE_SERVER=99.99.99.99 # your remote server IP - don't use name, use IP
REMOTE_SERVER_SSH_PORT=22 # your remote server SSH port
HOME_SERVER_REMOTE_SSH_PORT=5022 # the port your local server SSH will be accessible from remote
SSH_IDENTITY=# optional path to private ssh key, leave empty for default
REMOTE_USER=tunnel # remote user to login as
 
REMOTE_TO_HOME=\
"127.0.0.1:8080:127.0.0.1:80 "\
"127.0.0.1:8443:127.0.0.1:8443 "\
"0.0.0.0:6022:10.70.43.99:22 "\
"0.0.0.0:12112:127.0.0.1:12112 " # list of ports forwarded from remote to local
 
HOME_TO_REMOTE= # list of ports forwarded from local to remote

You can create as many tunnels as you like. Note that SSH port will always be forwarded anyway, so you want one file for each remote host.

Now create this script under /home/tunnel/tunnel.sh:

 

and set it as executable:

 > chmod +x /home/tunnel/tunnel.sh

Share tunnel's /home/tunnel/.ssh/id_rsa.pub with remote host, paste it inside authorized_hosts file of remote tunnel user.

This website uses technical cookies only. No information is shared with anybody or used in any way but provide the website in your browser.

More information