How to Install Mosh on AlmaLinux or Rocky Linux 9/8

Mosh is an abbreviation for “Mobile Shell” which is a remote terminal application for Linux and other OS platforms. It is designed to reduce latency and is a good alternative to traditional SSH where the network connection is unreliable. Mosh allows you to switch network connections without losing the session and even if you lose it, Mosh will automatically connect again when it comes online, maintaining persistent connectivity.

Furthermore, to enhance productivity, Mosh predicts user input and locally echoes it, providing a smoother typing experience even with network delays. Ofcourse, like SSH, the encryption will be there to exchange the data from server to client and vice-versa securely.

Well, to use Mosh on AlmaLinux or Rocky, we need to install the “Mosh Client” package, and here in this tutorial, we learn how to do that.

Step 1: Installing EPEL 8 or 9

The mosh package is not available through the default repository of AlmaLinux and Rocky Linux, so we need to enable EPEL (Extra package repository for Enterprise Linux) repo as per the version of Linux we are using.

  • Commands to enable “EPEL 9” on AlmaLinux or Rocky 9 Linux distro release users:
sudo dnf config-manager --set-enabled crb
sudo dnf install epel-release
  • Commands to install “EPEL 8” for Almalinux or Rocky 8 Linux OS users:
sudo dnf config-manager --set-enabled powertools
sudo dnf install epel-release

Step 2: Update Package Manager

After enabling the EPEL repository, the second step is to run the system update command on our Linux system to ensure the DNF package manager can update the package index cache and recognize the packages available through the newly enabled repository.

sudo dnf update

Step 3: Install Mosh on Almalinux or Rocky

Once the system is updated by running the previous step’s command, we can easily use the DNF to install the MOSH terminal application to connect the remote servers. Here is the command to follow:

sudo dnf install mosh
Installing Mosh on Almalinux
Mosh commands

Step 4: Allow Mosh Through Firewall (Optional)

If you have a firewall enabled, you may need to allow Mosh connections. Run the following commands:

sudo firewall-cmd --permanent --add-service=mosh
sudo firewall-cmd --reload

Step 5: Connect the remote server with Mosh

Mosh is not different, the command line is similar to SSH and is also used for connecting the remote computer as well, hence, if the remote server has the SSh server running then to connect it using the Mosh use the given command syntax:

mosh username@server_address

Replace the username with the remote server’s user and the address with its IP address or domain.

For example:

mosh [email protected]
connecting remote computer wiht Mosh

Note: If you get the “Connection closed by UNKNOWN port 65535 /usr/bin/mosh: Did not find the remote IP address (is SSH ProxyCommand disabled?).” error, then either the remote server Address is wrong or the SSH server on the remote server is not installed or responding; or SSH port is not opened on the remote system.

Other Articles:

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.