How can I use Mobile Shell (Mosh) to connect to MSI servers?

What is Mosh?

Mosh (mobile shell) is a drop-in replacement for ssh for remote access to MSI servers. It is robust to intermittent disconnections from the network and changes in IP address, such as with weak or overbooked Wi-Fi signals.

How to Install Mosh

Windows

Unfortunately, there is not a native program to run mosh on Windows. You can install the Google Chrome extension (https://chrome.google.com/webstore/detail/mosh/ooiklbnjmhbcgemelgfhaeaocllobloj), or use Cygwin (https://www.cygwin.com/) to install a Windows version of mosh.

MacOSX

Mosh can be installed with the .pkg file that is distributed from their server (https://mosh.org/#getting), or installed with the Homebrew package manager (https://brew.sh/).

Linux and Other UNIX

Mosh is available as pre-built packages most Linux distributions. As of September 2018, there are packages for Alpine, Arch, Debian, Fedora, openSUSE, and Ubuntu, with emerge for Gentoo systems. Mosh is also available in the ports trees of FreeBSD, OpenBSD, NetBSD, and OpenCSW.

Connect to MSI Login Node

Currently, the only login node that supports mosh is “login01.” To use mosh to connect to this node, open a terminal emulator and type the following command:

 

mosh <X.500>@login01.msi.umn.edu

 

Where <X.500> is your UMN X.500 internet ID. You may be prompted to verify the identity of the host machine. From there, you can connect to an interactive HPC session, or to the head node of a non-interactive HPC system to submit jobs.

Typical Use Case

The use case for mosh is one in which you need responsive and persistent connections across intermittent network connectivity. Therefore, mosh is more likely to be helpful on the Saint Paul campus of our university than on the East Bank or West Bank campuses. Anecdotally, mosh has successfully maintained connection to MSI through computer sleeps and building transitions, for example, when moving a laptop from an office to a seminar room.

Caveats and Limitations

Mosh currently does not support X11 forwarding, so graphical applications will not work over a mosh connection.

 

Mosh does not have a replacement for “scp” - if you need support for remote file transfer over intermittent connections, you should use “rsync,” which can resume transfers that did not complete successfully.

 

Mosh is only available for connection to the login node from your local terminal. It will not be used to connect to Mesabi or Itasca, once you are connected to the login node. Mosh does not support multi-hop connections like ssh does. You can, however, “chain” mosh and ssh commands, just like you can with ssh (see question 2 in the FAQ).

 

Mosh will not allow you to connect to MSI servers or maintain a connection to MSI servers during downtime or maintenance periods. Additionally, host reboots will sever any existing connections, and you will have to reconnect from your local terminal once the servers are back online.

Frequently Asked Questions

  1. Does mosh bypass the requirement to be on-campus or tunneling through the UofM VPN?
    Mosh does not bypass this requirement. You must be connecting through the UMN network to access MSI servers.

     
  2. I have a multi-hop setup for ssh, and I would like to replicate that with mosh. How can I get similar functionality?
    Mosh does not support multi-hop connections like ssh does. However, you can issue an ssh command to the login shell that you start with mosh:

    mosh <X.500>@login01.msi.umn.edu ssh mesabi

    This will use mosh to connect to the login node, and then use ssh to connect you to the Mesabi head node. Please note, though, that if you disconnect from the network for longer than 30 seconds (the ssh timeout limit) then your ssh connection from the login node to the Mesabi head node may be killed. This may be mitigated by using GNU screen or tmux once you are connected to the login node.

     
  3. I can no longer view my terminal scrollback when using mosh. How can I get it back?

    This is a known limitation of mosh. It only synchronizes the visible text between the server and the local terminal. A workaround to get scrollback is to use GNU screen or tmux.
Category: 
interactive