walle Posted April 22, 2023 Share Posted April 22, 2023 (edited) On my Debian based servers, I use systemd to make sure my reverse SSH tunnel starts at boot and make sure it's running. Now I want to do similar to my Unraid server. What is the equivalent to this file [Unit] Description=My AutoSSH tunnel service After=network.target [Service] Environment="AUTOSSH_GATETIME=0" ExecStart=/usr/bin/autossh -M 0 -o ServerAliveInterval=60 -o ServerAliveCountMax=3 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -NTi /etc/ssh/id_ed25519 -R 1234:localhost:22 [email protected] [Install] WantedBy=multi-user.target ? Edited April 22, 2023 by walle Typo in codesnippet Quote Link to comment
apandey Posted April 22, 2023 Share Posted April 22, 2023 /config/go.txt is a startup script for unraid, if all you want is trigger something on every boot The user scripts plugin also allows you to schedule scripts at various triggers and events - like cron, array start / stop etc. Further, what you want to do might be possible via a docker container which can be set to auto start with array Quote Link to comment
walle Posted April 22, 2023 Author Share Posted April 22, 2023 Thank you for your rely Apandey. Currently I have this bottom of the go-file: # Autossh relay /usr/bin/autossh -M 0 -o ServerAliveInterval=60 -o ServerAliveCountMax=3 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -NTfi /etc/ssh/id_ed25519 -R 1234:localhost:22 [email protected] The thing is autossh instance sometimes dies without any apparent reason. I have seen behavior for a few of my other servers where I have initiated autossh with a cronjob. This is quite worrisome for me sense this may be the only way I can remotely connect to the server. The other servers I have runs autossh with systemd have worked flawlessly. This is why I want to run autossh as a service/demon or whatever else that is similar to systemd and that works even if the array haven't started. So I don't think either user scripts or Docker based solutions will not work for me. Quote Link to comment
apandey Posted April 23, 2023 Share Posted April 23, 2023 If you could run it via cron, user scripts would do it for you. It has a cron trigger I don't understand why docker won't work. That is the preferred way to run things on unraid What is your use case for the tunnel? Maybe unraid already had a preferred way to do that Quote Link to comment
walle Posted April 23, 2023 Author Share Posted April 23, 2023 (edited) My use case is my Unraid server is behind a CG-NAT, aka. the public IP number is shared, so it isn't possible to SSH to the server directly over the internet. The workaround I have for this is to let the server connect via a tunnel to a VPS. When I need to access my server remotely, I do a reverse tunnel connection via the VPS to my server. In other words, If the tunnel goes down, I can no longer access the server. In order to keep the tunnel alive, I currently use autossh and trigger it in the GO-file. But this doesn't seem to be enough, sense I have seen autossh process die time to time. So I need some kind of solution that can monitor autossh and restart it when needed. I don't think, as far as I know, either cron or user scripts plugin can do that. In regards to Docker, it's normally my go-to solution to solve most of my problems and could maybe partly solves the issue with health checks. But I don't think it's a good fit in this case for two reasons. First of all, I don't want to SSH into the container and I think there is no good way to "break out" from it in order to access the host. Second, Docker will not run unless the array have started. I need to have remote access to server even if the array goes down or the array can't start for some reason. Edited April 24, 2023 by walle Clerefying CG-NAT and typo. Quote Link to comment
JonathanM Posted April 26, 2023 Share Posted April 26, 2023 Perhaps it would be better to build a lightweight PC based router with your tunnel and failsafes built in so your whole network is available with the proper firewall rules. Quote Link to comment
walle Posted April 26, 2023 Author Share Posted April 26, 2023 Humm, good idea. My router is a Unifi console and maybe possible to run autossh with a demon on that. Otherwise my plan B is to run a Raspberry PI with Rasbian + autossh and use the configuration I mentioned in my first post. In case of autossh fails on my Unraid server, I can still login via the pi to the network. Quote Link to comment
apandey Posted April 27, 2023 Share Posted April 27, 2023 On 4/26/2023 at 8:58 AM, JonathanM said: Perhaps it would be better to build a lightweight PC based router with your tunnel and failsafes built in so your whole network is available with the proper firewall rules That is what I have, pfSense with VPN server. All network security happens here and availability is not a concern due to focused application. Unraid is then just another appliance on the inside then Quote Link to comment
walle Posted April 27, 2023 Author Share Posted April 27, 2023 (edited) I looked into if it was possible to run autossh as a demon on my Unifi console, it seems to not be possible (without do a bunch of hacky stuff). Put a Raspberry PI on the network is most likely workaround I will probably do if it can't be solved with Unraid. Edited April 27, 2023 by walle Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.