Note - This is to be set client side only and not server side. Amazon AWS usually drops your connection after only 60 seconds of inactivity, so this option will ping the server every 50 seconds and keep you connected indefinitely. Many graphical SSH clients, like SecureCRT or PuTTY, also have options for sending null packets, NOOPs, or keepalive, just look in their options. You can set a keep alive option in your /.ssh/config file on the clients home dir: ServerAliveInterval 50. By default it’s three, so if your remote host doesn’t respond in three intervals it’ll close the connection. ![]() There is also the ServerAliveCountMax, which governs how many times it’ll try keeping the session alive before it closes it. In these examples 120 is the number of seconds between keepalives. Last, you could always stick it in the main client config file, usually /etc/ssh/ssh_config: ServerAliveInterval 120 The Host part of this configuration can also be set to a specific host, or a specific pattern (look in the ssh_config man page, way at the end under PATTERNS), if you have varying needs. If you don’t already have a ~/.ssh/config file make sure to chmod it to 600 so it doesn’t complain about permissions. ![]() Better yet, you could also put it in ~/.ssh/config so it always takes effect: Host * You can do it from the command line: ssh -o ServerAliveInterval=120 Īnd you could alias ssh to “ssh -o ServerAliveInterval=120” in. SSH protocol version 2 supports server keepalive, essentially NOOPs sent to the server to keep the connection up. I could ask our network guys to change the timeouts, but it turns out there’s a better fix from the client side. Let the connection sit for a while and you’ll have to recreate it. It also happens in various other situations, like NAT through a home router, too. It’s particularly inconvenient when I’m tailing a log that hasn’t changed in a while… and then the connection dies, and I don’t notice. With the installation of new firewalls at work I’ve been getting disconnected a lot from hosts I SSH to, due to changes in the inactivity timeouts.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |