How to Reliably Keep an SSH Tunnel Open in Server?

By Hardik Savani December 21, 2021 Category : Ubuntu Server

This article will give you example of how to keep ssh tunnel open. I’m going to show you about ubuntu keep ssh tunnel alive. if you want to see example of server keep alive ssh tunnel then you are a right place. i explained simply step by step how to keep ssh tunnel open. follow bellow step for how to keep ssh connection open example.

We can create ssh tunnel using 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:

Example 1:

Syntax:

ssh -f -N -L 13307:127.0.0.1:3306 user_name@server_ip

Example:

ssh -f -N -L 13307:127.0.0.1:3306 root@167.111.111.111

Example 2:

Syntax:

autossh -M 20000 -f -N your_public_server -R 1234:localhost:22 -C

Example:

sudo apt-get install autossh

autossh -M 20000 -f -N your_public_server -R 1234:localhost:22 -C

i hope it can help you...

Tags :
Shares