mosh README

The project's README from github.com/mobile-shell/mosh. As one markdown file: README.md.

ci

Mosh: the mobile shell

Mosh is a remote terminal application that supports intermittent connectivity, allows roaming, and provides speculative local echo and line editing of user keystrokes.

It aims to support the typical interactive uses of SSH, plus:

Mosh does not support X forwarding or the non-interactive uses of SSH, including port forwarding.

Other features

Getting Mosh

The Mosh web site has information about packages for many operating systems, as well as instructions for building from source.

Note that mosh-client receives an AES session key as an environment variable. If you are porting Mosh to a new operating system, please make sure that a running process's environment variables are not readable by other users. We have confirmed that this is the case on GNU/Linux, OS X, and FreeBSD.

Usage

The mosh-client binary must exist on the user's machine, and the mosh-server binary on the remote host.

The user runs:

$ mosh [user@]host

If the mosh-client or mosh-server binaries live outside the user's $PATH, mosh accepts the arguments --client=PATH and --server=PATH to select alternate locations. More options are documented in the mosh(1) manual page.

There are more examples and a FAQ on the Mosh web site.

How it works

The mosh program will SSH to user@host to establish the connection. SSH may prompt the user for a password or use public-key authentication to log in.

From this point, mosh runs the mosh-server process (as the user) on the server machine. The server process listens on a high UDP port and sends its port number and an AES-128 secret key back to the client over SSH. The SSH connection is then shut down and the terminal session begins over UDP.

If the client changes IP addresses, the server will begin sending to the client on the new IP address within a few seconds.

To function, Mosh requires UDP datagrams to be passed between client and server. By default, mosh uses a port number between 60000 and 61000, but the user can select a particular port with the -p option. Please note that the -p option has no effect on the port used by SSH.

Advice to distributors

A note on compiler flags: Mosh is security-sensitive code. When making automated builds for a binary package, we recommend passing the option --enable-compile-warnings=error to ./configure. On GNU/Linux with g++ or clang++, the package should compile cleanly with -Werror. Please report a bug if it doesn't.

Where available, Mosh builds with a variety of binary hardening flags such as -fstack-protector-all, -D_FORTIFY_SOURCE=2, etc. These provide proactive security against the possibility of a memory corruption bug in Mosh or one of the libraries it uses. For a full list of flags, search for HARDEN in configure.ac. The configure script detects which flags are supported by your compiler, and enables them automatically. To disable this detection, pass --disable-hardening to ./configure. Please report a bug if you have trouble with the default settings; we would like as many users as possible to be running a configuration as secure as possible.

Mosh ships with a default optimization setting of -O2. Some distributors have asked about changing this to -Os (which causes a compiler to prefer space optimizations to time optimizations). We have benchmarked with the included src/examples/benchmark program to test this. The results are that -O2 is 40% faster than -Os with g++ 4.6 on GNU/Linux, and 16% faster than -Os with clang++ 3.1 on Mac OS X. In both cases, -Os did produce a smaller binary (by up to 40%, saving almost 200 kilobytes on disk). While Mosh is not especially CPU intensive and mostly sits idle when the user is not typing, we think the results suggest that -O2 (the default) is preferable.

Our Debian and Fedora packaging presents Mosh as a single package. Mosh has a Perl dependency that is only required for client use. For some platforms, it may make sense to have separate mosh-server and mosh-client packages to allow mosh-server usage without Perl.

Notes for developers

To start contributing to Mosh, install the following dependencies:

Debian, Windows Subsystem for Linux:

$ sudo apt install -y build-essential protobuf-compiler \
    libprotobuf-dev pkg-config libutempter-dev zlib1g-dev libncurses5-dev \
    libssl-dev bash-completion tmux less

Fedora, RHEL:

$ sudo dnf group install development-tools
$ sudo dnf install automake protobuf-compiler protobuf-devel libutempter-devel \
    zlib-ng-compat-devel ncurses-devel openssl-devel bash-completion tmux less \
    perl-diagnostics

MacOS:

$ brew install protobuf automake

Once you have forked the repository, run the following to build and test Mosh:

$ ./autogen.sh
$ ./configure
$ make
$ make check

Mosh supports producing code coverage reports by tests, but this feature is disabled by default. To enable it, make sure lcov is installed on your system. Then, configure and run tests:

$ ./configure --enable-code-coverage
$ make check-code-coverage

This will run all tests and produce a coverage report in HTML form that can be opened with your favorite browser. Ideally, newly added code should strive for 90% (or better) incremental test coverage.

More info

mosh (mobile-shell/mosh)

Searching Database…

14.6K ·GitHub
What is this?Mosh (Mobile Shell) is a remote terminal application that replaces SSH for interactive sessions, keeping the connection alive through network changes, sleep, and lossy links while locally echoing keystrokes for instant feedback.
Is this a drop-in replacement for SSH, or does it work alongside it?It works alongside SSH: Mosh uses SSH only to establish the connection and authenticate, then switches the actual terminal session to its own UDP protocol.
How do I run it?Install the mosh-client binary on your machine and mosh-server on the remote host, then run 'mosh [user@]host'; if the binaries aren't on PATH you can point to them with --client=PATH and --server=PATH.
What do I need on both ends to make it work?You need SSH access to the remote host (for the initial handshake) plus the mosh-client and mosh-server binaries installed respectively, and UDP traffic (default port range 60000-61000) must be allowed between client and server.
What can't Mosh do compared to SSH?Mosh doesn't support X forwarding or non-interactive SSH uses like port forwarding, and it requires a UTF-8 environment to run.
Who benefits most from using this over plain SSH?People connecting over high-latency or unreliable links, such as cellular data or spotty Wi-Fi, or anyone who roams between networks and wants their terminal session to survive sleep or IP changes.
Which operating systems does it run on?Mosh runs on GNU/Linux, macOS, and FreeBSD, and the project provides packages for many operating systems.
How does local echo work without showing wrong characters after a typo?The client runs a predictive model of the server's behavior and underlines predicted keystrokes on high-latency links; it removes the underline once the server confirms them and automatically recovers from occasional prediction errors within one round-trip time.
How does the connection survive changing networks or sleep?The server keeps listening on its UDP port and session key even if the client goes offline; when the client reappears with a new IP (e.g., switching from Wi-Fi to cellular), the server starts sending to the new address within a few seconds.
Does Control-C still work if a remote program hangs?Yes, Mosh adjusts its frame rate to avoid filling network queues, so Control-C is guaranteed to take effect within one round-trip time even on slow links.
What are similar projects?tailcat, gost, xpra, shadowsocks-c, AceShell, OpenFlux, sshuttle, borg
Size
2.7 MB
Stars
14.6K
Age
15y
Commits · 90 Days