If you have trouble with SSH connections breaking, Jack Wallen shows you how you can enjoy a bit more persistence with the help of Eternal Terminal.
If you’re an admin with Linux servers in your data center or cloud hosted account (such as AWS and Google Cloud), chances are pretty good you connect to those machines via SSH. Sometimes you need to remain connected for a good amount of time. You could be debugging code, working on containers or Kubernetes, or just about a thousand other reasons.
Thing is, sometimes those SSH connections get disconnected. This could occur because of a change in IP address or a host of reasons. When that happens, you have to re-connect. I’ve had experiences where SSH was constantly losing its connection, causing me to have to constantly reconnect.
That’s frustrating and time consuming. What can you do to avoid it?
One way around this problem is by using Eternal Terminal (ET), in place of SSH. Eternal Terminal does a great job of re-establishing a connection to a remote machine, without user intervention. That means once you’ve connected, you’ll stay connected until you break the connection manually.
I want to show you how to install and use Eternal Terminal. You can use this tool on Linux, macOS, and even Windows (using WSL).
To make use of Eternal Terminal, you’ll need at least two systems that support the software and you must use Eternal Terminal on both remote and local machines. I’ll be installing ET on Ubuntu Server 20.04 and Ubuntu Desktop 20.04. As far as Linux is concerned, it can be installed on Debian-based distributions and CentOS (via the epel-release repository).
How to install Eternal Terminal
On Ubuntu (both server and desktop), the installation of Eternal Terminal is quite simple. Log in to either the server or desktop and install the software that allows you to add new repositories from PPAs with the command:
Where USER is the username on the remote server and SERVER is the IP address or domain of the remote server.
Eternal Terminal uses port 2022 by default–you’ll need to make sure that port is available.
As you use Eternal Terminal, you won’t find anything different than working with SSH, until a connection is broken, at which point ET will appear to be non-responsive. However, it will cache all keystrokes made at this point and, as soon as the connection is re-established, it will execute the cached commands.
Note: This only works if the connection is terminated on the remote side of things.
Of course there’s a caveat. If your connection is broken by the client machine, and not the remote server, an orphaned session is created and you cannot reconnect to that orphaned session. In order to reconnect to the remote server, you’ll have to manually kill the orphan first. This is done with the command: