Mosh, which means Mobile shell is a command-line application used to connect to a server from a client computer over the Internet. It can be used SSH and includes more features than Protected shell.
It is a similar application to SSH, but with additional features. The application was originally written by Keith Winstein For a Unix-like operating system and released under the GNU GPL v3.
Mosh facilities and services
- It is a remote decision application that supports roaming.
- Available for all major UNIX-type operating systems, including Linux, FreeBSD, Solaris, Mac OS X, and Android.
- Ad hoc connection supported.
- Provides smart local echo.
- Supported user keyboard line editing.
- Responsive design and sustainable nature via Wi-Fi, mobile and remote connections.
- Stay connected even if the IP changes. It uses UDP instead of TCP (used by SSH). TCP timeout when the connection is reset or a new IP is assigned, but UDP keeps the connection open.
- The connection remains intact when you resume the session after a long time.
- No network delay. Displays user-entered key and deletions immediately without network delay.
- Same old way to log in as in SSH.
- Mechanism for handling packet loss.
Installing Mosh Shell on Linux
On Debian, Ubuntu and Mint on similar systems, you can install Mosh package using the apt-get package manager, as shown.
# apt-get update # apt-get install mosh
On RHEL/CentOS/Fedora distribution, you must turn on the third-party archive named EPEL, so you can install this archive using the mosh-yum package manager as shown.
# yum update # yum install mosh
On Fedora 22+ version, you need to use the dnf package manager to install mosh as shown.
# dnf install mosh
It can be installed on other Linux distributions as shown.
# pacman -S mosh [On Arch/Manjaro Linux] $ sudo zypper in mosh [On OpenSuse] # emerge net-misc/mosh [On Gentoo]
How do I use Mosh Shell?
1. Trying to log in to a remote Linux server with a mosh shell.
$ mosh [email protected]
Entry: Did you see that I got an error connecting because the port was not open on the remote control CentOS 7 box. The quick but not recommended solution was:
# systemctl stop firewalld [on Remote Server]
The primary way is to open the port and update the firewall rules. And then connect to the mosh on a predefined port. For more information about the firewall, see this message.
- Configuring the firewall in CentOS, RHEL, and Fedora
2. Assume that the default SSH port 22 was changed to port 70, in this case you can specify a custom port ‘-p‘switch mosh.
$ mosh -p 70 [email protected]
3. Check the version of the installed Mosh version.
$ mosh --version
4. You can close the mosh session type ‘exit‘prompt.
5. Mosh supports many options you may see:
$ mosh --help
Cons of Mosh Shell
- Mosh requires additional conditions, such as allowing a direct connection over UDP, which SSH did not require.
- Dynamic port allocation in the area 60000-61000. The first open fort is reserved. It requires one port per connection.
- Default port reservation is a serious concern, especially in production.
- IPv6 connections are supported, but roaming with IPv6 is not supported.
- Scrolling is not supported.
- X11 forwarding is not supported.
- No support for ssh agent forwarding.
Mosh is a nice little utility that can be downloaded from the archive of most Linux distributions. While it has a few inconsistencies, specifically related to security and additional requirements, its features include staying connected while roaming. I recommend that every Linux user working on SSH should try this application and keep it in mind, Mosh is worth a try.
If you appreciate what we do here at TecMint, you need to consider:
TecMint is the fastest growing and most trusted community site for all kinds of Linux articles, guides, and books online. Millions of people visit TecMint! Search or browse thousands of published articles that are accessible to everyone.