Skip to content

Instantly share code, notes, and snippets.

@nilbus
Last active March 19, 2021 09:10
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nilbus/4953758 to your computer and use it in GitHub Desktop.
Save nilbus/4953758 to your computer and use it in GitHub Desktop.
Getting mosh (mobile-shell) working with cygwin

Getting mosh on cygwin to work was a little challenging, so I want to share how I got it.

First, install mosh on the server and the client (with cygwin's setup.exe)

When I tried to connect to a mosh server from a cygwin terminal

mosh my-server.com

I would get these errors:

mosh-server needs a UTF-8 native locale to run.

Unfortunately, the local environment ([no charset variables]) specifies
the character set "US-ASCII",

The client-supplied environment ([no charset variables]) specifies
the character set "US-ASCII".

LANG=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=
Connection closed.

Despite setting locale environment variables, they were not being passed over ssh to the server. To fix this, send the environments manually to mosh-server.

mosh --server='mosh-server new -l LANG=en_US.UTF-8' my-server.com

This is more effective as an alias in .bashrc:

alias mosh="mosh --server='mosh-server new -l LANG=en_US.UTF-8'"

Then just connect as usual:

mosh my-server.com

My server's firewall did not by default allow port UDP 60000-61000, so I inserted this rule in my iptables firewall:

sudo iptables -I INPUT 1 -p udp -m multiport --dports 60000:61000 -j ACCEPT

Hurray! It all works now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment