Keeping your SSH Client From Timing Out

Published by John on May 11, 2018 Under Website Hosting

Magento LogoOne of my Magento Clients uses MageMojo for website hosting, which bills themselves as a hosting company optimized to host Magento ecommerce websites.

I’m not a fan of the type of pricing model MageMojo and similar hosting companies use, like WP Engine, where instead of billing for more tangible and meaningful resources, such as CPU Usage, Memory, Hard Disk space, Bandwidth, etc, they charge you per visitor or per-visitor session.

However, MageMojo does seem to do a good job at hosting Magento sites. They provide decent support and have optimized their system to make things like setting up caching through redis or varnish much easier, as well as some other optimizations to help run Magento Smoother and ensure that it stays up to date with security updates.

One issue I had run into however, was that my SSH client would quickly timeout when logged into their server remotely. This doesn’t happen with any of the other machines I regularly ssh into, but it was impossible to dump a Mysql database or even compress/extract a large file, without getting logged out.

On their support site, they state that they don’t enforce a timeout on SSH sessions, although this is the only server I run into with this issue, so I would be surprised if something with the way their infrastructure is setup is causing the session to get rejected quickly. They suggest to fix this by adjusting the KeepAlive setting in your SSH client, although don’t provide an example of this.

In any-case, the fix is relatively easy. In your ssh config file, add the below. If you don’t have an ssh config file create it first. It should be located at ~/.ssh/config

Host *.magemojo.com
    ServerAliveInterval 30
    ServerAliveCountMax 10

After adding this, you should be able to stay logged in when preforming larger tasks, like dumping that 1+ GB Magento database or creating a manual backup of your website.

Host *.magemojo.com tells your SSH Client that the below section should only apply when connecting to a magemojo.com host. You could also use just a single asterick(*) to apply to all hosts or get more specific and only apply it to your actual ssh host, like myserver.magemojo.com

ServerAliveInterval tells your SSH Client to send a signal to the SSH Host Server every 30 seconds to let it know you are still working.

ServerAliveCountMax is the number of times your SSH Client will send the alive message to the SSH Host Server without receiving a response before it disconnects you.

The ~/.ssh/config file is a local setting and so only applies to the user you are logged in as. If you wanted to apply to all users on your machine, you could edit the main config file located at: /etc/sshd/ssh_config


No Comments |

Add a Comment