Keeping Your SSH Sessions Alive Through NAT Firewalls

I found this article Keeping Your SSH Sessions Alive Through Pesky NAT Firewalls which explained how to keep SSH connections alive through NAT firewalls. I’m behind a NAT router and my SSH connections are always timing out due to inactivity, and it annoys the shit out of me. I’ve been putting up with it for ages, and tonight I finally got around to searching for a solution. The solution is to edit your ~/.ssh/config file and add:

Host *
    ServerAliveInterval 240

That will make the server send a keep-alive packet every four minutes, which out to do it. Haven’t tried it yet, but expect it will work. Will configure my systems now…

Update: that didn’t seem to work for me. :(

Maybe this is a client setting?

Anyway, I did some more research, and I found that PuTTY has a configuration option in the Connection settings “Sending of null packets to keep session active”, “Seconds between keepalives” which defaults to 0 (turned off). So I’m gonna try with that now.