ci Mosh: the mobile shell Mosh is a remote terminal application that supports…
- User
User: 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 keeps the session alive if the client goes to sleep and wakes up later, or temporarily loses its Internet connection.
Mosh allows the client and server to "roam" and change IP addresses, while keeping the connection alive. Unlike SSH, Mosh can be used while switching between Wi-Fi networks or from Wi-Fi to cellular data to wired Ethernet.
The Mosh client runs a predictive model of the server's behavior in the background and tries to guess intelligently how each keystroke will affect the screen state. When it is confident in its predictions, it will show them to the user while waiting for confirmation from the server. Most typing and uses of the left- and right-arrow keys can be echoed immediately.
As a result, Mosh is usable on high-latency links, e.g. on a cellular data connection or spotty Wi-Fi. In distinction from previous attempts at local echo modes in other protocols, Mosh works properly with full-screen applications such as emacs, vi, alpine, and irssi, and automatically recovers from occasional prediction errors within an RTT. On high-latency links, Mosh underlines its predictions while they are outstanding and removes the underline when they are confirmed by the server.
Mosh does not support X forwarding or the non-interactive uses of SSH, including port forwarding.
Other features Mosh adjusts its frame rate so as not to fill up network queues on slow links, so "Control-C" always works within an RTT to halt a runaway process.
Mosh warns the user when it has not heard from the server in a while.
Mosh supports lossy links that lose a significant fraction of their packets.
Mosh handles some Unicode edge cases better than SSH and existing terminal emulators by themselves, but requires a UTF-8 environment to run.
Mosh leverages SSH to set up the connection and authenticate users. Mosh does not contain any privileged (root) code.
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:
PATH, mosh accepts the arguments --client=PATH and --server=PATH to select alternate locations. More options are documented in the mosh(1) manual page.
- Assistant
Mosh 本身并不具备内网穿透的功能。它在本质上还是一个需要网络连接的终端工具,依赖于 UDP 协议来保持会话的持续性和稳定性。因此,如果您的服务器位于 NAT 网络或防火墙后面,您需要确保以下几点以便成功连接:
-
端口转发:确保在 NAT 路由器或防火墙上设置了端口转发,将外部的 UDP 请求转发到服务器的 Mosh 端口(通常是范围 60000 到 61000 之间的任意端口)。
-
防火墙配置:服务器的防火墙应允许 Mosh 使用的 UDP 端口范围的流量通过。
-
使用 SSH 登录:Mosh 在启动时需要通过 SSH 来进行用户身份验证,所以确保 SSH 可以正常访问。
如果您需要访问位于内网后面的服务器,可能需要使用其它工具或策略(例如 VPN 或基于代理的解决方案)来实现外网访问。这些工具可以帮助您穿透内网和 NAT,提供到服务器的直接连接。同时,诸如 ngrok 这样的内网穿透工具可以在某些情况下搭配使用,具体根据您的网络架构和需求而定。
-