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 配合使用?它和 SSH 配合使用:Mosh 只借助 SSH 建立连接和完成身份验证,之后就把实际的终端会话切换到它自己的 UDP 协议上。
我该怎么运行它?在本机安装 mosh-client 程序,在远程主机上安装 mosh-server,然后运行 'mosh [user@]host';如果这些程序不在 PATH 中,可以用 --client=PATH 和 --server=PATH 指定它们的位置。
两端需要准备什么才能正常使用?你需要能通过 SSH 访问远程主机(用于初始握手),并在两端分别安装 mosh-client 和 mosh-server 程序;客户端与服务器之间还必须允许 UDP 流量通过(默认端口范围为 60000-61000)。
和 SSH 相比,Mosh 不能做什么?Mosh 不支持 X 转发,也不支持端口转发等非交互式的 SSH 用途;它还要求运行在 UTF-8 环境中。
相比普通 SSH,谁最能从 Mosh 中受益?经常通过高延迟或不稳定链路连接的人,比如使用蜂窝数据或信号时好时坏的 Wi-Fi 的人;以及需要在不同网络之间切换,并希望终端会话在电脑休眠或 IP 变化后依然保持的人。
它能在哪些操作系统上运行?Mosh 可在 GNU/Linux、macOS 和 FreeBSD 上运行,项目也为多种其他操作系统提供了安装包。
本地回显是怎么工作的?打错字之后不会显示错误字符吗?客户端会运行一个预测模型,用来推测服务器的行为,并在高延迟链路上为预测的按键加下划线;服务器确认这些按键后,下划线就会去掉。若偶尔出现预测错误,它会在一次往返时间内自动恢复。
如果网络切换或电脑休眠,连接怎么保持?即使客户端离线,服务器仍会在自己的 UDP 端口和会话密钥上持续监听;当客户端以新 IP 重新出现时(例如从 Wi-Fi 切换到蜂窝网络),服务器会在几秒内开始向新地址发送数据。
如果远程程序卡住,Control-C 还能用吗?可以。Mosh 会调整帧率,避免占满网络队列,因此即使在慢速链路上,Control-C 也能保证在一次往返时间内生效。
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