I have this service file to make a reverse SSH, works fine, on the other server I can see it, problem is I left it over night, in the morning I've checked the service was active but on the other server when running netstat, it wasn't listening anymore, so it lost the connection overnight even though the service was active.
Is this normal? What could I do to not loose the connection at all? When I restarted the service it reconnected again with no problems.
If in the service I use autossh instead of ssh, would it solve this problem?
sudo netstat -tulpn | grep LISTEN
tcp 0 0 0.0.0.0:2222 0.0.0.0:* LISTEN 22024/sshd: ec2-use
[Unit]
Description=SSH Tunnel Service
After=network-online.target
Wants=network-online.target
[Service]
User=alex
Environment="PATH=/usr/bin:/bin:/usr/local/bin"
ExecStart=/usr/bin/ssh -i /home/alex/lightsail.pem -N -R 2222:localhost:22 ec2-user@server
Restart=always
RestartSec=10
[Install]
WantedBy=default.target