How to prevent your SSH session from disconnect while being idle?

Dariusz Mydlarz
Nov 26, 2020

Recently I found a really annoying thing. My SSH sessions to remote servers were being disconnected while I was not actively using them for a certain period of time (even a couple of minutes).

Fortunately, I have found a solution. Very simple solution.

Send keep-alive messages

In order to prevent it, you have to add entry yo your .ssh/config file

Host *
ServerAliveInterval 60

That’s it!

Now your SSH remote sessions will not be disconnected even if you’re not actively using them for a certain amount of time.

Voila! :)

--

--

Dariusz Mydlarz

Software Engineer keen on delivering best value for the business