Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Enable keepalives in Plink

We are using Plink for a tunnel to a MySQL. We are using it in this format:

plink.exe -L [Port of our client]:[my-sql server host name]:3306 [bridge server ssh username]@[bridge server IP] -i [private key]

We cannot find an option to prevent the connection to be closed, a sort of keepalive.

How could we achieve this?

like image 467
Matioski Avatar asked Apr 18 '18 08:04

Matioski


2 Answers

Instead of a keepalive that plink manages internally, another option is to use the shell that is created on the host to keep sending short bits of data on the wire. This can be done through a very simple shell script such as:

while true;
do echo 0;
sleep 30s;
done

This very simple bash script will write the character 0 every 30 seconds to the screen.

A full example of the whole command line when invoking plink:

plink -P 443 [user@]host.com -R *:80:127.0.0.1:80 -C -T while true; do echo 0; sleep 30s; done
like image 52
fleed Avatar answered Oct 12 '22 19:10

fleed


Plink does not have any command-line option for keepaliaves.

All you can do is to configure a stored session in PuTTY GUI with the keepalive on and then re-use the session in Plink using -load switch.

like image 25
Martin Prikryl Avatar answered Oct 12 '22 18:10

Martin Prikryl