Wednesday, January 10, 2018

Mosh (Mobile Shell) – Best Alternative for SSH to Connect Remote System

https://www.2daygeek.com/install-mosh-shell-ssh-client-in-linux-to-connect-remote-system

SSH is one of the best option to connect remote Linux systems. It’s very famous and widely used application. We have wrote many articles about SSH and it’s security, just hit the link to know more about it.

What’s Mosh

Mosh stands for (mobile shell) is a remote terminal application that supports intermittent connectivity, allows roaming, and provides intelligent local echo and line editing of user keystrokes.
It’s similar to SSH and offer more features. Mosh is a replacement for SSH and more robust and responsive. Especially, it will keep the session alive when you move over/between the networks like Wi-Fi to wired Ethernet, wired Ethernet to cellular data, cellular data to Wi-Fi.

How it’s work

Mosh, initially establish the remote connection through SSH and uses the same credentials, the executes the unprivileged mosh-server helper program on the server finally closes the SSH connection and starts the mosh-client.
Mosh does not support X forwarding or the non-interactive uses of SSH, including port forwarding. Mosh is free software, available for GNU/Linux, BSD, macOS, Solaris, Android, Chrome, and iOS.

Mosh Features

  • Mosh keeps the session alive if the client goes to sleep and wakes up later, or temporary internet disconnection.
  • Mosh allows the client and server to “roam” and change IP addresses, when you move between the netwrk without disconnection.
  • Mosh warns the user about internet disconnection and reconnect when network available.
  • It gives an instant response when you typing, deleting, and line editing, even in slow network because it runs a predictive model of the server’s behavior in the background and guess keystroke intelligently.
  • Mosh doesn’t required root privilege to run.
  • Mosh connects through UDP and doesn’t listen on network ports or authenticate users but initially establish the connection through SSH (from client to server) and uses the same credentials.
  • Mosh handles packet loss gracefully, since its based on UDP.
  • Mosh supports lossy links that lose a significant fraction of their packets.
  • Mosh handles some Unicode edge cases better than SSH and existing terminal emulators by themselves, but requires a UTF-8 environment to run.
  • Mosh uses dynamic UDP ports from 60000 to 61000

How to install Mosh

Mosh package is available in distribution official repository, so we can easily install through package manager.
For Debian Users, use Apt package manager or Apt-get package manager.
$ sudo apt install mosh
For CentOS/RHEL Users, enable EPEL repository and use yum package manager.
$ sudo yum install mosh
For Fedora Users, use dnf package manager.
$ sudo dnf install mosh
For openSUSE Users, use zypper package manager.
$ sudo zypper install mosh
For Arch Linux Users, use pacman package manager.
$ sudo packman -S mosh

How to use Mosh

Use the following standard format to connect Mosh. User your system IP and username instead of us.
$ mosh root@192.168.1.100
Run the following nc command to check the connection established UDP port with Mosh.
$ nc -zu 192.168.1.100 60000-61000
Note : Make sure, you have to open the UDP ports from 60000 to 61000 on firewall to allow Mosh to establish the connection.
As we told in beginning of the article, Mosh will notify users about network disconnection and resume the connection when its available. See the below screenshot.

To check Mosh version.
$ mosh -version
mosh 1.2.6 [build mosh 1.2.6]
Copyright 2012 Keith Winstein 
License GPLv3+: GNU GPL version 3 or later .
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
To exit from Mosh.
$ exit
After exit from Mosh, you will get the similar output.
$ mosh root@192.168.1.100
root@192.168.1.100's password: 


[mosh is exiting.]
To know more about Mosh option.
$ man mosh
or
$ mosh --help

No comments:

Post a Comment