How to Install Mosh Shell as SSH Alternative on Linux
How to Install Mosh Shell as SSH Alternative on Linux
Mosh (Mobile Shell) is a powerful alternative to traditional SSH (Secure Shell) that is designed to provide a better experience for remote command line sessions, especially in environments with unreliable or fluctuating network conditions. Mosh offers features like automatic reconnection, predictive text input, and the ability to move between networks without dropping your session. In this comprehensive guide, we will explore how to install Mosh on Linux, its key features, and how it can enhance your remote work experience.
What is Mosh?
Mosh is an open-source tool that allows users to maintain persistent SSH-like sessions with numerous advantages:
Persistent Sessions: Mosh maintains sessions even when the network connection drops or the client moves between networks (e.g., from Wi-Fi to cellular).
Predictive Input: Mosh predicts what you are typing and displays the text in real time, making the experience feel snappier, especially on slow connections.
Low Latency: By using UDP (User Datagram Protocol) instead of TCP, Mosh reduces latency and improves the responsiveness of the shell.
Why Use Mosh?
Using Mosh offers several significant benefits over traditional SSH:
Improved User Experience: Mosh’s predictive input and low latency make typing commands feel more responsive, especially in high-latency environments.
Seamless Network Transitions: Users can switch between different networks without losing their active sessions.
Automatic Reconnection: If the connection is interrupted, Mosh will automatically attempt to reconnect when the network becomes available again.
Less Bandwidth Usage: Mosh’s design is optimized for low-bandwidth conditions, making it suitable for remote work over cellular or unstable networks.
Prerequisites
Before installing Mosh, ensure you have the following:
Linux Distribution: This guide is suitable for various Linux distributions, including Ubuntu, Fedora, and CentOS.
Basic Terminal Knowledge: Familiarity with terminal commands will help you navigate the installation process effectively.
Step 1: Install Mosh
The installation process for Mosh can vary depending on your Linux distribution. Below are the instructions for popular distributions.
1. For Ubuntu/Debian
Open your terminal and run the following commands:
sudo apt update
sudo apt install mosh
2. For Fedora
To install Mosh on Fedora, use the following command:
sudo dnf install mosh
3. For CentOS/RHEL
For CentOS or RHEL, you may need to enable the EPEL repository first:
sudo yum install epel-release
sudo yum install mosh
4. For Arch Linux
For Arch Linux users, Mosh can be installed via the official repositories:
sudo pacman -S mosh
Step 2: Configure the Server
Mosh requires that both the client and server have the Mosh package installed. Once you have installed Mosh on your local machine, you will also need to ensure it is installed on any server you plan to connect to.
1. SSH into the Server
Use SSH to connect to your server:
ssh username@server_ip
2. Install Mosh on the Server
Repeat the installation steps above for your server’s operating system.
Step 3: Using Mosh
After installing Mosh on both your local machine and server, you can start using it. Follow these steps to initiate a Mosh session:
1. Start a Mosh Session
From your local terminal, use the following command to start a Mosh session:
mosh username@server_ip
2. Specifying Ports (Optional)
By default, Mosh uses UDP ports in the range of 60000 to 61000. If your network configuration requires specific port usage, you can specify a different port range with the –port option:
mosh –port=60001:60010 username@server_ip
3. Session Resilience
If you lose your connection due to network issues, Mosh will automatically attempt to reconnect when the connection is restored. Simply run the same Mosh command again if you wish to reconnect manually.
Step 4: Key Features of Mosh
Mosh offers several unique features that can greatly enhance your remote working experience:
1. Predictive Text Input
One of the standout features of Mosh is its predictive text input, which allows you to see what you are typing in real-time. This is particularly useful for long commands, as it reduces the frustration often associated with lag.
2. Session Locking
If you are concerned about security, Mosh allows for session locking. This feature helps prevent unauthorized access to your session while you are away. You can enable it by using the –lock option:
mosh –lock username@server_ip
3. Customizable UDP Ports
As mentioned, Mosh can operate on a specified range of UDP ports. This is beneficial for firewall configurations, allowing you to define which ports to open or close based on your network security requirements.
4. UTF-8 Support
Mosh supports UTF-8 encoding, making it suitable for languages that use non-Latin scripts. This feature enhances usability for international users and developers working with diverse character sets.
Thank you for visiting our site. If you want, you can read our other related articles by clicking the link below.
How to Download and Use tmate on Linux
Conclusion
Mosh is a robust alternative to traditional SSH that significantly improves the experience of remote command line sessions. With its features like persistent sessions, predictive input, and seamless network transitions, Mosh is an invaluable tool for anyone who relies on remote access to servers.
By following this guide, you have learned how to install Mosh on your Linux system and leverage its powerful features to enhance your remote work experience. Whether you are a developer, system administrator, or someone who frequently manages remote servers, Mosh can streamline your workflow and make remote connections more enjoyable. Embrace the power of Mosh and transform the way you interact with remote systems!