This article will give you an example of how to keep the ssh tunnel open. I’m going to show you about ubuntu keeps the ssh tunnel alive. if you want to see an example of a server keeping alive an ssh tunnel then you are in the right place.
I explained simply step by step how to keep the ssh tunnel open. follow the below steps for how to keep the ssh connection open example. We can create an ssh tunnel using the ssh command, how to keep them alive, so here I will give you simple examples how to create ssh tunnel and keep alive then.
let's see bellow command:
ssh -f -N -L 13307:127.0.0.1:3306 user_name@server_ip
Or you can use:
sudo apt-get install autossh autossh -M 20000 -f -N your_public_server -R 1234:localhost:22 -C
Hope it can help you.