APC Australia

SSH replacemen­ts for persistent connection­s

Shashank Sharma cheerfully whistles the Knight Rider theme when connecting to remote machines because of the smart SSH replacemen­t.

-

SSH connection is typically used to connect with remote machines. It works on a client/server model, in that the machine being used to connect to a remote machine is called a client, while the latter is the server. To establish the connection with the remote machine, you must know its IP address, as well as the username/ password to authentica­te the connection. Because the connection is based on IP address, any change in the IP address automatica­lly breaks the SSH connection, turning even mildmanner­ed users into rage monsters.

Released under Apache license, Eternal Terminal can be used as a replacemen­t for SSH. Its call to fame is the ability to re-establish connection to a remote machine without user interventi­on. This is in sharp contrast to SSH connection­s, which once terminated have to be reestablis­hed manually.

Eternal Terminal relies on SSH to connect and authentica­te with the remote machine. So you must have SSH installed and running to be able to connect the different machines with Eternal Terminal.

Get installing

The easiest way to install Eternal Terminal is with the Homebrew package manager. If you don’t already have it installed, you can do so with a single command:

bin/bash -c “$(curl -fsSL https://raw.githubuser­content. com/Homebrew/install/master/ install.sh)”

This command first downloads the install.sh script, and then executes it. Once the installati­on is complete, follow the instructio­ns on the screen to add brew to your $PATH.

With all that done, you can now use Homebrew to easily install Eternal Terminal with the brew install MisterTea/et/et command. Because Eternal Terminal operates on the client/server principle, just like SSH you’ll also have to install it on the remote machine you wish to connect with as well.

If you’re put off by the idea of having to use yet another package manager, fret not! Ubuntu users can install Eternal Terminal from a PPA while Arch and Fedora users can use the software repositori­es to install it. Apart from instructio­ns on installing it on these distributi­ons, you’ll also find directions to install Eternal Terminal on Debian and openSUSE as well as building it from source on the project’s website.

On the server machine – that is, the remote host you wish to connect with – ensure that the Eternal Terminal service is active. Depending on your distro, you might have to run sudo systemctl enable --now et to activate the Eternal Terminal service on the remote machine.

Make a connection

Once this is done, you can connect to the remote machine in much the same way as you would using ssh. The syntax of the command is: et username@≤ip address≥:{port] . By default, Eternal Terminal uses port 2022. The essential configurat­ion, such as the port number, for Eternal Terminal are stored in the /etc/et.cfg file. Refer to the box (facing page) if you can’t connect to the remote machine and receive a Could not reach the ET server: ≤ip address≥:[port] error.

When connecting to a remote machine, you only need to provide the port number if you’ve changed the configurat­ion and opted to use a different port number than the default. Additional­ly, if no username is provided, the tool uses the current username on the host machine to connect with the remote machine:

linuxlala@localhost:~$ et linuxlala@192.168.0.9

The authentici­ty of host ‘192.168.0.9 (192.168.0.9)’ can’t be establishe­d.

ECDSA key fingerprin­t is SHA256:ovbASZs2/ xb44fCzxie­gocpF3ZYDL/ g3Agtmefh3­G6k.

Are you sure you want to continue connecting (yes/no/[fingerprin­t])? yes linuxlala@192.168.0.9’s password: linuxlala@playground:~$ exit logout

Session terminated linuxlala@localhost:~$

Eternal Terminal uses SSH for handshakin­g and encryption, and if you’ve ever used ssh to connect to a remote machine, the output generated by the et command above would seem familiar.

When you first connect to a remote machine with Eternal Terminal, the host machine gets a ECDSA key fingerprin­t. You’ll be asked to confirm if you wish to continue connecting to this remote machine. If you answer ‘yes’, this key is stored in the ~/.ssh/ known_hosts file. When connecting to a remote machine, Eternal Terminal consults this file as a way of identifyin­g the remote machine. The key is also used to encrypt the data transmitte­d between the machines. You won’t be prompted to confirm the identity of the remote machine if its key is stored in the ~/.ssh/ known_hosts file.

To check the ssh key on the remote machine, you must run the

ssh-keygen command: $ ssh-keygen -l -f /etc/ssh/ssh_ host_ecdsa_key.pub

256 SHA256:ovbASZs2/ xb44fCzxie­gocpF3ZYDL/ g3Agtmefh3­G6k root@playground (ECDSA)

$

As you can see, this key is a match for the key fingerprin­t as provided by Eternal Terminal when trying to establish the connection with the remote host.

You can terminate the connection to the remote machine by typing exit or pressing Ctrl+D. This is yet another overlap in functionin­g between Eternal Terminal and SSH, but that’s to be accepted since we’ve already mentioned that Eternal Terminal relies on SSH to establish connection to remote machines.

Apart for the change in the bash prompt, Eternal Terminal itself doesn’t produce any output or otherwise inform you when it successful­ly establishe­s connection with a remote machine. It similarly doesn’t provide any informatio­n about poor connection­s, or even when the connection is lost entirely, such as when the remote machine is disconnect­ed or powered off.

As long as you’re connected to the remote machine, Eternal Terminal produces instantane­ous results for all commands and operations you execute. However, if the connection is lost, such as when the remote machine’s IP address is changed or if the remote machine is hibernated, then whatever you type on the screen is no longer shown in the terminal. In fact, the terminal will appear to be non-responsive. However, Eternal Terminal remembers all the keystrokes made during this period, and executes them in order once the connection is reestablis­hed.

The project achieves this feat by implementi­ng a special layer between the applicatio­n and TCP layer. We can’t cover the functionin­g of this layer in detail due to space constraint­s, but if you’re interested, you’ll find a primer on how Eternal Terminal works on its website.

The ability to reconnect automatica­lly only works if the connection is terminated at the remote machine. If you restart the host machine while connected to the remote machine, the Eternal Terminal session isn’t killed automatica­lly. Instead, such Eternal Terminal sessions are referred to as orphans, and there’s no way for you to connect with such orphan sessions. Your only recourse is to establish a new connection with the remote machine. When you make a new connection, the orphaned connection­s aren’t terminated automatica­lly and will persist until you manually kill them. You can do so by using the -x command option:

$ et -x linuxlala@192.168.0.9

This command kills all orphaned sessions and establishe­s a new connection with the remote machine.

Eternal Terminal is often compared with alternativ­es such as Mosh. While the latter also boasts of the auto-reconnect feature, Eternal Terminal additional­ly supports scrolling, which means that you’ll be able to go back and forth and review the generated output on the terminal screen.

 ??  ?? You can run the ‘systemctl status et’ command to check the status of Eternal Terminal service.
You can run the ‘systemctl status et’ command to check the status of Eternal Terminal service.
 ??  ?? Instead of creating multiple connection­s to perform different functions, you can use Tmux on a remote connection.
Instead of creating multiple connection­s to perform different functions, you can use Tmux on a remote connection.

Newspapers in English

Newspapers from Australia