Introducing portSSHare: a Dockerized AutoSSH Tunneling Solution for Easy Port Forwarding reddit / selfhosted ---------------------------------------------------------------------- Human_Umpire7073 · 2023-12-23 22:33 **Title:** Introducing portSSHare: a Dockerized AutoSSH Tunneling Solution for Easy Port Forwarding **Body:** Hey r/selfhosted community! I'm excited to share a project I've been working on that might interest those of you into self-hosting and network management. It's a Dockerized AutoSSH setup designed for easy and reliable port forwarding. **What It Does:** The project uses AutoSSH within a Docker container to establish persistent SSH tunnels. This setup is particularly useful for forwarding ports from machines on a private network to a machine on an upstream network, effectively allowing services on a private network to be accessible from a more public-facing server. **Key Features:** - **Simplicity:** Everything is managed via a straightforward YAML config file. - **Flexibility:** Supports multiple SSH tunnel configurations. - **Portability:** Being Dockerized, it can run virtually anywhere Docker is supported. **How It Works:** You specify your tunnel configurations in a `config.yaml` file, which includes parameters like source and target SSH users, hosts, ports, etc. The Docker container then reads this file and sets up the specified SSH tunnels using AutoSSH. **Example Config:** Here’s a simplified version of the config structure: ```yaml tunnel1_source_ssh_user: user1 tunnel1_source_host: source1.example.com tunnel1_source_port: 8080 tunnel1_target_ssh_user: user2 tunnel1_target_host: target.example.com tunnel1_target_port: 9090 tunnel2_source_ssh_user: user3 tunnel2_source_host: source2.example.com tunnel2_source_port: 8000 tunnel2_target_ssh_user: user4 tunnel2_target_host: target.example.com tunnel2_target_port: 9000 ``` **Why I Made This:** I often found myself needing a reliable way to expose services running on various home lab servers to the internet or other networks. While there are many ways to achieve this, I wanted something simple and easily reproducible. Hence, this project! **Looking for Feedback:** I'd love to get feedback from the community. Suggestions for improvements, feature requests, or general thoughts are all welcome. **GitHub Repo:** I've made the project open-source, and it's available on GitHub: [GitHub Link to Your Repo] Feel free to check it out, use it in your setups, and contribute if you find it useful! --- **Note:** - Ensure you have a GitHub repository link to include in the post for interested users to access your project. - Modify any parts of the post to better fit your project details or personal style. - Remember to engage with the community respectfully, especially when responding to questions or feedback. ---------------------------------------------------------------------- epsiblivion · 2023-12-23 23:42 you should let config.yaml be a volume bindmount rather than copied during build time. ---------------------------------------------------------------------- Human_Umpire7073 · 2023-12-24 00:05 Thank you so much for your feedback! I have the config.yaml as a volume bindmount in the [compose file](https://github.com/davidhfranke lcodes/portsshare/blob/main/docker-compose.yaml). Thank you for citing rapiz1/rathole. I read it and see that it is a very robust service. ---------------------------------------------------------------------- ctrl-brk · 2023-12-24 01:33 I would like to see you build a docker image and using only environment variables in docker compose, establish the tunnels. No config file, just env. Thanks for sharing ---------------------------------------------------------------------- Human_Umpire7073 · 2023-12-24 01:45 Thank you for replying! Yes env file is easier to manage typically. ---------------------------------------------------------------------- WiseCookie69 · 2023-12-24 10:20 * Why the need for 2 tunnels per configuration? * You can just forward to a service's tcp/udp port and call it a day. * I also use autossh and I just pass-through port XY on my remote server to port XY on my destination. Like port 443 for HTTPs and port 5013 for traccar. Requiring an SSH-access on the target just doesn't make sense - even more though, if the target is containerized. * Why disabling host key checking? * That's a core security feature of SSH and you're already requiring the use of a configuration file. So providing a server's public keys is fairly trivial. * Don't use `latest` tags - not even in `Dockerfiles` * If you want to use yaml, use something like `yq` to parse the configuration. Currently, you could basically just `source` it in your script, if you were to replace the `:` with `=`. ---------------------------------------------------------------------- Human_Umpire7073 · 2023-12-24 15:43 I'm using 2 tunnels per config because this app is a man-in-the- middle. ​ I don't know whay you meant by disabling host key checking. Can you explain what part of the project does that and what the implications are? This one I just didn't understand. ​ I guess I can pin it to a specific alpine. ​ You're right and other users said that env file would be easier than yaml. Agree but keeping it like this for now. ​ Thank you!!! ---------------------------------------------------------------------- Independent_Till5832 · 2023-12-27 15:57 -o "StrictHostKeyChecking=no" in the arguments of autossh ---------------------------------------------------------------------- Human_Umpire7073 · 2023-12-28 02:37 Oh! Ok so that's because the container could fail to start asking the user for permission to add the host to the known\_hosts. If it's sitting there waiting for you to say yes then the container won't start.