Mobile Shell (Mosh)

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 Mosh Chrome extension, or use Cygwin to install a Windows version of mosh.

MacOSX

Mosh can be installed with the .pkg file that is distributed from the Mosh server, or installed with the Homebrew package manager.

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

Agate login nodes have mosh installed, a new connection can be initiated with the command:

 

mosh <internetID>@agate.msi.umn.edu

 

where <internetID> is your UMN internet ID. You may be prompted to verify the identity of the host machine. From there, you can start a Slurm job or reconnect to an existing job. Please note that our compute nodes do not support mosh, so after connecting to a login node you will need to use ssh to connect directly to a compute node. See question 2 in the FAQ below.

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 a login node from your local terminal. It cannot be used to connect to a compute node once you are connected to agate. 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 below..

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 <InternetID>@agate.msi.umn.edu ssh [compute node]

    This will use mosh to connect to an agate login node, and then use ssh to connect you to a specified compute 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 compute 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.

Discover Advanced Computing and Data Solutions at MSI

Our Services
Was this page helpful?
If you have a question about MSI services, please submit a ticket through our Help Desk