User Tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
selfhost:ssh_tunnel [2024/01/25 13:03] – created willyselfhost:ssh_tunnel [2024/02/08 17:28] (current) – removed willy
Line 1: Line 1:
- 
- 
-===== 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**: 
-<code bash> 
- > useradd -m tunnel 
- > su - tunnel 
- > ssh-keygen 
- > mkdir tunnels 
- > mkdir logs 
-</code> 
- 
-Add tunnels configurations like this under **/home/tunnel/tunnels/main**: 
-<file txt 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 
-</file> 
- 
-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**: 
-<code bash> 
- 
- 
-</code> 
- 
-and set it as executable: 
-<code bash> 
- > chmod +x /home/tunnel/tunnel.sh 
-</code> 
- 
-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