


So to reach my NAS from the internet, I simply need to create an SSH tunnel between my NAS and my VPS, that reliably stays open all the time (for round the clock access). Therefore, to reach my NAS, I have a VPS (which I rent from OVH for a very small monthly cost), and that has a fixed public IP address. I have a NAS that I want to reach from the internet, I can't use port forwarding because my ISP uses CGNAT (my public IP is not really my public IP, I'm behind another router I don't have any control over). Upstart script on Ubuntu, where /etc/inittab is not available: start on net-device-up IFACE=eth0Įxec ssh -i /path/to/rsaKey -N -o "ServerAliveInterval 180" -R 55002:localhost:22 scriptįor those who don't want to (or) can't use AutoSSH. etc/inittab, to have access to a box shipped and installed in another country, behind NAT, without port forwarding to the box, you can configure it to create an ssh tunnel back to you: tun1:2345:respawn:/usr/bin/ssh -i /path/to/rsaKey -f -N -o "ServerAliveInterval 180" -R 55002:localhost:22 'sleep 365d' sleep 5 done) do not remove the sleep command, ssh may fail quickly and you'll respawn too many processes Always use ServerAliveInterval SSH option in case the tunnel issues are generated by expired NAT sessions.Īlways use a respawning method in case the connectivity goes down entirely, you have at least three options here:
