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
Что это такое?Mosh (Mobile Shell) — приложение для удалённого терминала, которое заменяет SSH для интерактивных сеансов. Оно сохраняет соединение при смене сети, переходе в спящий режим и нестабильной связи, а нажатия клавиш показывает локально, чтобы отклик был мгновенным.
Это полная замена SSH или она работает вместе с ним?Работает вместе с SSH: Mosh использует SSH только для установки соединения и проверки подлинности, а затем переводит сам терминальный сеанс на собственный протокол UDP.
Как его запустить?Установите исполняемый файл mosh-client на своём компьютере и mosh-server на удалённом хосте, затем выполните 'mosh [user@]host'. Если исполняемые файлы не находятся в PATH, можно указать путь к ним с помощью --client=PATH и --server=PATH.
Что нужно с обеих сторон, чтобы всё работало?Нужен доступ по SSH к удалённому хосту (для первоначального обмена) и установленные исполняемые файлы: mosh-client на клиенте и mosh-server на сервере соответственно. Кроме того, между клиентом и сервером должен быть разрешён трафик UDP (диапазон портов по умолчанию 60000-61000).
Чего Mosh не умеет по сравнению с SSH?Mosh не поддерживает X forwarding и неинтерактивные сценарии SSH, например проброс портов, а также требует окружения с UTF-8.
Кому выгоднее использовать это вместо обычного SSH?Тем, кто подключается через линии с высокой задержкой или ненадёжные каналы, например мобильный интернет или нестабильный Wi-Fi, а также тем, кто часто переходит между сетями и хочет, чтобы терминальный сеанс переживал сон компьютера или смену IP-адреса.
На каких операционных системах это работает?Mosh работает на GNU/Linux, macOS и FreeBSD, а проект также предоставляет пакеты для многих других операционных систем.
Как работает локальный вывод символов, чтобы после опечатки не показывались неверные символы?Клиент запускает прогнозирующую модель поведения сервера и подчёркивает предсказанные нажатия на линиях с высокой задержкой. Как только сервер подтверждает их, подчёркивание убирается, а редкие ошибки предсказания автоматически исправляются за один цикл туда-обратно (RTT).
Как соединение переживает смену сети или сон?Сервер продолжает слушать свой UDP-порт и ключ сеанса, даже если клиент отключился от сети. Когда клиент снова появляется с новым IP-адресом (например, переключился с Wi-Fi на мобильный интернет), сервер начинает отправлять данные на новый адрес в течение нескольких секунд.
Сработает ли Control-C, если удалённая программа зависла?Да. Mosh регулирует частоту кадров, чтобы не забивать сетевые очереди, поэтому Control-C гарантированно срабатывает за один цикл RTT даже на медленных каналах.
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