MOSH(1)
โจ MOSH(1) โ mobile shell, but make it bestie-core โจ
okay so bestie, welcome to the mosh manual. this is the part where we read the whole thing together, no skimming, because every flag matters. ๐
๐ธ NAME ๐ธ
mosh โ mobile shell with roaming and intelligent local echo. that's the name, that's the game, no cap. ๐ฆ
๐ SYNOPSIS ๐
mosh [options] [--] [user@]host [command...]
๐ DESCRIPTION ๐
okay so mosh (mobile shell) is a remote terminal application that supports intermittent connectivity, allows roaming, and provides speculative local echo and line editing of user keystrokes. ngl it's literally built for when your wifi is giving chaotic and your laptop keeps changing its IP. โจ
compared with ssh, mosh is more robust โ its connections stay up across sleeps and changes in the client's IP address โ and more responsive, because the protocol is tolerant of packet loss and the client can echo most keystrokes immediately, without waiting for a network round-trip. so yeah, the latency? not the main character here. ๐
mosh uses ssh to establish a connection to the remote host and authenticate with existing means (e.g., public-key authentication or a password). then mosh executes the unprivileged mosh-server helper program on the server, then closes the SSH connection and starts the mosh-client, which establishes a long-lived datagram connection over UDP. it's giving "handoff, but make it seamless." ๐
to improve responsiveness, mosh runs a predictive model of the server's behavior in the background, trying to guess the effect of each keystroke on the screen. it makes predictions for normal typing, backspace, and the left- and right-arrow keys. when it is confident, mosh displays the predictions without waiting for the server. the predictive model must prove itself anew on each row of the terminal and after each control character, so mosh avoids echoing passwords or non-echoing editor commands. no spoilers for your secrets, periodt. ๐
by default, mosh shows its predictions only on high-latency connections and to smooth out network glitches. (on longer-latency links, the predicted cells are underlined until confirmed by the server.) occasional echo mistakes are corrected within a network round-trip and do not cause lasting effect. so if you see a lil typo prediction, don't panic, it's lowkey temporary. ๐ญ
mosh does not support X forwarding or the non-interactive uses of SSH, including port forwarding or sshfs. mosh works through typical client-side network address translators but requires UDP to pass between client and server. by default, mosh uses the ports between 60000 and 61000, but allows the user to request a particular UDP port instead. so like, it's not trying to be everything, it's just trying to be the bestie that keeps your terminal alive. ๐
currently, mosh has limited support for IPv6, dual-stack networks, and servers with multiple addresses. at session start, it will select a single IPv4 or IPv6 server address to connect to for the lifetime of the session. one address, one session, no flip-flopping. ๐ธ
mosh will do its best to arrange a UTF-8 character set locale on the client and server. the client must have locale-related environment variables that specify UTF-8. mosh will pass these client variables to the mosh-server on its command line, but in most cases they will not need to be used. mosh-server first attempts to use its own locale-related environment variables, which come from the system default configuration (sometimes /etc/default/locale) or from having been passed over the SSH connection. but if these variables don't call for the use of UTF-8, mosh-server will apply the locale-related environment variables from the client and try again. so it's literally trying its best to make your emojis and accents work. ๐ซถ
โจ OPTIONS โจ
options named --experimental-* are subject to change or removal in future versions of Mosh; their design or function is not yet final. bestie, do not build your whole personality on experimental flags. they ate, but they might leave. ๐
commandโ command to run on remote host. by default,moshexecutes a login shell. so if you want something else, say it. ๐--client=PATHโ path to client helper on local machine (default:"mosh-client"). that's the local bestie doing the work. ๐--server=COMMANDโ command to run server helper on remote machine (default:"mosh-server").
the server helper is unprivileged and can be installed in the user's home directory. no root required, we love that for us. ๐
this option can be used to set environment variables for the server by using the env(1) command to wrap the actual server command. see mosh-server(1) for available environment variables. iykyk. โจ
--ssh=COMMANDโ OpenSSH command to remotely executemosh-serveron remote machine (default:"ssh").
an alternate ssh port can be specified with, e.g., --ssh="ssh -p 2222". so if your ssh is on a weird port, you can still slay. ๐ฅ
--ssh-pty,--no-ssh-ptyโ enable or disable ssh's use of a pty when connecting to a remote host. the default is enabled. pty on by default, okay? ๐--predict=WHENโ controls use of speculative local echo.WHENdefaults toadaptive(show predictions on slower links and to smooth out network glitches) and can also bealwaysornever.
the MOSH_PREDICTION_DISPLAY environment variable controls this setting permanently and can adopt the same three values. set it and forget it. โจ
even on always, mosh will only show predictions when it is confident. this generally means a previous prediction on the same row of the terminal has been confirmed by the server, without any intervening control character keystrokes. so no wild guesses, only certified vibes. ๐
-aโ synonym for--predict=always. all the predictions, all the time. ๐-nโ synonym for--predict=never. no predictions, no surprises. ๐ง--predict-overwriteโ when prediction is enabled, do not insert speculative local echo before existing text, but overwrite it instead.
the MOSH_PREDICTION_OVERWRITE environment variable also enables this if its value is 'yes'. so yes means overwrite mode. ๐
-oโ synonym for--predict-overwrite. cute, short, iconic. ๐--family=inetโ only use IPv4 for the SSH connection and Mosh session. old school but reliable. ๐--family=inet6โ only use IPv6 for the SSH connection and Mosh session. this and the following modes require Perl'sIO::Socket::IPorIO::Socket::INET6modules. so check your Perl modules, bestie. ๐ฆ--family=autoโ autodetect IPv4 or IPv6 for hosts that only have addresses in a single family. hosts with both IPv4 and IPv6 addresses will raise an error, and require re-invocation ofmoshwith another--familyoption. so dual-stack hosts? not this one. ๐ญ--family=allโ choose an address from all available IPv4 or IPv6 address, even for dual-stack hosts. this is the most convenient option, but requires dual-stack connectivity, and Mosh 1.2.5 or later on the server, when roaming with dual-stack servers. convenient but with conditions, fr fr. โจ--family=prefer-inetโ similar to--family=all, but attempt connects to the IPv4 addresses first. this is the default. so IPv4 gets first dibs. ๐--family=prefer-inet6โ similar to--family=all, but attempt connects to the IPv6 addresses first. IPv6 first, periodt. ๐ธ-4โ synonym for--family=inet. four, but make it IPv4. ๐ข-6โ synonym for--family=inet6. six, but make it IPv6. ๐ข-p PORT[:PORT2],--port=PORT[:PORT2]โ use a particular server-side UDP port or port range, for example, if this is the only port that is forwarded through a firewall to the server. with-p 0, the server will let the operating system pick an available UDP port. otherwise,moshwill choose a port between60000and61000. please note that this option does not affect the server-side port used by SSH. so firewall bestie, this one's for you. ๐ฅ--bind-server={ssh|any|IP}โ control the IP address that themosh-serverbinds to.
the default is ssh, in which case the server will reply from the IP address that the SSH connection came from (as found in the SSH_CONNECTION environment variable). this is useful for multihomed servers. so it replies from where ssh came from. ๐
with --bind-server=any, the server will reply on the default interface and will not bind to a particular IP address. this can be useful if the connection is made through sslh or another tool that makes the SSH connection appear to come from localhost. localhost vibes, but make it intentional. โจ
with --bind-server=IP, the server will attempt to bind to the specified IP address. you pick the IP, it tries to bind. ๐
--no-initโ do not send thesmcupinitialization string andrmcupdeinitialization string to the client's terminal. on many terminals this disables alternate screen mode. so if you hate alternate screen, this is your moment. ๐ซถ--localโ invokemosh-serverlocally, without usingssh. this option requires the host argument to be a local, numeric IPv4/IPv6 address. this option is useful for testing. local testing era. ๐งช--experimental-remote-ip={proxy|local|remote}โ select the method used to discover the IP address that themosh-clientconnects to.
the default is proxy, which uses SSH's --ssh-proxy-command option to generate and report the exact address that ssh uses to connect to the remote host. this option is generally the most compatible with hosts and other options configured in ssh configuration files. however, this may not work for some configurations, or for environments where a ssh bastion host forwards to a remote machine. it only works with OpenSSH. so OpenSSH only, bestie. ๐
with remote, the server's SSH_CONNECTION environment variable will be used. this is useful for environments where ssh forwarding is used, or the --ssh-proxy-command option is used for other purposes. remote said "i got this." โจ
with local, Mosh resolves the hostname given on its command line, and uses that address for both ssh and Mosh connections. this option ignores any configuration in ssh_config for the same hostname. local means local, no ssh_config drama. ๐ธ
๐ฎ ESCAPE SEQUENCES ๐ฎ
the default escape character used by Mosh is ASCII RS (decimal 30). this is typically typed as Ctrl-^ or Ctrl-Shift-6, on US English keyboards. users of non-English keyboards may find it difficult or impossible to type the default escape character, and may need to change the escape character. see the description of MOSH_ESCAPE_KEY, below. in this description, the configured escape character is represented as Esc. okay so Esc is just our shorthand, don't @ me. ๐
there are two slightly different modes for escape sequences, depending whether the escape character is printable or not. so vibe check your escape char. โจ
if the escape character is a printable character, it must be prefixed with a newline, similar to OpenSSH. to send the escape character itself, type it twice. if the escape character is set to ~, mosh will behave much like OpenSSH. so ~ is giving very OpenSSH-coded. ๐
if the escape character is a non-printable control character, no prefix is used and the escape character is recognized at any time. to send the escape character itself, type the escape character, then its corresponding ASCII character (for Ctrl-^ you would type ^, for Ctrl-B you would type B). so Ctrl-^ then ^, got it? ๐ซถ
the escape sequence to shut down the connection is Esc .. the sequence Esc Ctrl-Z suspends the client. any other sequence passes both characters through to the server. so Esc . is the peace out, Esc Ctrl-Z is the pause, and everything else goes to the server. periodt. ๐
๐ธ ENVIRONMENT VARIABLES ๐ธ
Okay bestie, listen โ these variables are not actually interpreted by mosh(1) itself, no cap. They get passed straight through to mosh-server(1). They're listed here just so your life is easier, because digging through another manpage at 2am is not the vibe. ๐ซถ
๐ MOSH_ESCAPE_KEY
When you set this, it configures the escape character used for local commands. The escape character can be any ASCII character in the range 1-127. โจ
Fr fr, the variable must be set with a single literal ASCII character. And for control characters? You set them with the actual ASCII control character โ not some printable stand-in like "^B". Do not do the printable thing. It will not slay.
๐ฆ MOSH_PREDICTION_DISPLAY
This one controls local echo, as described above (iykyk). ๐ And heads up: the command-line flag overrides this variable. Flag wins, always. Periodt.
๐ MOSH_TITLE_NOPREFIX
When set, this inhibits prepending "[mosh]" to the window title. That's it, that's the whole thing. A little toggle with main character energy. ๐
๐ฅ SEE ALSO ๐ฅ
Project home page: https://mosh.org ๐
๐ AUTHOR ๐
mosh was written by Keith Winstein <mosh-devel@mit.edu>. Absolute legend, honestly. โญ
๐ BUGS ๐
Please report bugs to mosh-devel@mit.edu. ๐
Users may also subscribe to the mosh-users@mit.edu mailing list, at http://mailman.mit.edu/mailman/listinfo/mosh-users ๐ธ
And that's a wrap, bestie! This page is from April 2013 โ yes, 2013, it's giving vintage but it still eats โ and it's the MOSH(1) manual page. Go forth and roam. ๐โจ
๐ฆ where this page comes from
- alpine 3.22: mosh-doc 1.4.0-r14 ยท GPL-3.0-or-later
- alpine 3.23: mosh-doc 1.4.0-r18 ยท GPL-3.0-or-later
- alpine 3.24: mosh-doc 1.4.0-r18 ยท GPL-3.0-or-later
- arch rolling: mosh 1.4.0-35 ยท GPL-3.0-only
- debian bookworm: mosh 1.4.0-1+b1 ยท GPL-3.0-or-later WITH OpenSSL exception
- debian trixie: mosh 1.4.0-1+b2 ยท GPL-3.0-or-later WITH OpenSSL exception
- epel 10: mosh 1.4.0-7.el10_0 ยท GPL-3.0-or-later
- epel 9: mosh 1.4.0-1.el9 ยท GPLv3+
- fedora 43: mosh 1.4.0-9.fc43 ยท GPL-3.0-or-later
- fedora 44: mosh 1.4.0-10.fc44 ยท GPL-3.0-or-later
- nixos 26.05: mosh 1.4.0
- nixpkgs unstable: mosh 1.4.0
- opensuse-leap 16.0: mosh 1.4.0-bp160.1.1 ยท GPL-3.0-or-later
- opensuse-leap 16.0: mosh 1.4.0-bp160.1.1 ยท GPL-3.0-or-later
- opensuse-leap 16.0: mosh 1.4.0-bp160.1.1 ยท GPL-3.0-or-later
- opensuse-leap 16.0: mosh 1.4.0-bp160.1.1 ยท GPL-3.0-or-later
- ubuntu noble: mosh 1.4.0-1ubuntu3 ยท GPL-3.0-or-later WITH OpenSSL exception
- ubuntu questing: mosh 1.4.0-1ubuntu4
- ubuntu resolute: mosh 1.4.0-1ubuntu5 ยท GPL-3.0-or-later WITH OpenSSL exception
- ubuntu stonking: mosh 1.4.0-1ubuntu6 ยท GPL-3.0-or-later WITH OpenSSL exception
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms