Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-2024-08-06· OpenAIAi2 WildChat-4.8M (AI2)

ci Mosh: the mobile shell Mosh is a remote terminal application that supports…

  1. 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:

    mosh[user@]hostIfthemosh−clientormosh−serverbinariesliveoutsidetheuser′smosh [user@]host If the mosh-client or mosh-server binaries live outside the user'sPATH, 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 optim

    这是什么项目 Assistant: 这是关于一个名为 Mosh 的远程终端应用程序的项目说明。Mosh,或称为“移动 Shell”,是一种支持不间断连接、允许漫游并提供用户按键预测本地回显和行编辑的远程终端应用。与传统的 SSH(Secure Shell)不同,Mosh 通过以下特点提升了用户体验:

    1. 保持会话活动:即使客户端设备进入休眠状态并稍后唤醒,或暂时失去 Internet 连接,会话仍会保持活动状态。

    2. 支持漫游:客户端和服务器可以更改 IP 地址而保持会话连接,使得 Mosh 可以在客户端在不同网络之间切换(如从 Wi-Fi 切换到蜂窝数据或有线网络)时继续使用。

    3. 预测回显:客户端运行一个服务器行为的预测模型,智能地猜测每次按键如何影响屏幕状态,并在对于预测有信心时,会在等待服务器确认期间向用户展示预测结果。这样在高延迟链接(例如蜂窝数据连接或不稳定的 Wi-Fi)上使用 Mosh 也很顺畅。

    4. 不支持某些 SSH 功能:Mosh 不支持 X 转发或 SSH 的非交互式功能,如端口转发。

    Mosh 依赖 SSH 设置连接和认证用户,但在会话开始后转而使用 UDP 进行通信,这使得它在应对网络不稳定性和高延迟方面表现优异。

    有关此项目的更多信息,包括安装、使用说明和其他技术细节,可在 Mosh 官方网站上找到。 User: 如何安装 Assistant: 要安装 Mosh,您可以根据您的操作系统按照以下步骤进行:

    在 Ubuntu/Debian 上:

    1. 打开终端。
    2. 更新软件包列表:
      sudo apt update
      
    3. 安装 Mosh:
      sudo apt install mosh
      

    在 CentOS/RHEL 上:

    1. 打开终端。
    2. 确保 EPEL 仓库已启用(如果未启用):
      sudo yum install epel-release
      
    3. 安装 Mosh:
      sudo yum install mosh
      

    在 macOS 上:

    1. 使用 Homebrew(如果未安装 Homebrew,请先到https://brew.sh/安装):
      brew install mosh
      

    在 Windows 上:

    Mosh 没有原生的 Windows 客户端,但您可以使用 Windows Subsystem for Linux (WSL) 在 Windows 上运行 Linux 版本的 Mosh。

    1. 设置 WSL,并安装 Ubuntu 或其他 Linux 发行版。
    2. 在 WSL 的终端中,按照 Ubuntu 的安装步骤进行安装。

    从源代码编译:

    1. 首先确保安装了必要的开发工具和库。
    2. 从 Mosh 的官方网站或 GitHub 仓库获取源码。
    3. 解压缩并进入源码目录。
    4. 运行以下命令以编译和安装:
      ./configure
      make
      sudo make install
      

    总之,Mosh 支持多种操作系统,而且通过包管理器进行安装通常是最简单的方式。如果需要更多的安装信息,可以访问 Mosh 的官方网站 查看详细的安装指导。 User: 安装后然后嘞 Assistant: 安装 Mosh 后,您可以按照以下步骤开始使用它:

    1. 确保服务器端已安装 Mosh:

      • 您要连接的远程服务器上也需要安装 Mosh,通常与本地的安装过程相似。
      • 确保服务器的防火墙允许 UDP 数据包通过,默认端口范围是 60000 到 61000。
    2. 使用 Mosh 连接到远程服务器:

      • 在终端中运行以下命令来启动 Mosh 会话:
        mosh [username@]hostname
        
      • 替换 username 为您的远程服务器用户名和 hostname 为服务器的地址或 IP。
      • Mosh 初始会使用 SSH 进行认证登录,因此 SSH 必须在服务器上正常运行。
    3. 会话使用:

      • 成功连接后,您将看到与 SSH 类似的终端界面,可以正常进行命令行操作。
      • 在切换网络或网络不稳定时,Mosh 会自动保持连接。
    4. 额外选项:

      • 如果 mosh-client 或 mosh-server 不在默认路径中,可以通过 --client=PATH 和 --server=PATH 指定路径。
      • 使用 mosh --help 可以查看更多命令行选项。
    5. 结束会话:

      • 直接在终端中输入 exit 或 logout 命令结束 Mosh 会话。

    借助 Mosh 的特点,即使在网络状况不佳或切换网络的情况下,您都能享受稳定而连续的终端会话。 User: 意思在被控端也要安装 Assistant:

  2. Assistant

    是的,确实如此。在您想要使用 Mosh 连接的远程服务器上也需要安装 Mosh。这是因为 Mosh 包括两个组件:mosh-client 和 mosh-server。本地机器上运行的是 mosh-client,而远程服务器上需要运行 mosh-server。当您使用 Mosh 连接到远程服务器时,Mosh 会先通过 SSH 登录到服务器,然后在服务器上启动 mosh-server 进程,以建立并管理终端会话。因此,确保在服务器端安装 Mosh 是正常使用的前提条件。