Mar 20, 2017
When configuring servers I've been connecting with plain ssh and making edits with mg (Micro Emacs) text editor running on tmux session. Though having used mosh previously I stopped using it at some point and forgot to set it on for my current Contabo VPS.
Mosh "The Mobile Shell" is a simple replacement for the regular ssh command that enchances the ssh client with few cool tricks. For me the main benefits are that it allows connections to persist over network changes and it helps reducing effects of network latency when working with command line tools (very good when working with mobile data connection). It installs nicely for both systems:
sudo apt-get install mosh on Linux and
brew install mobile-shell on OSX side. Server with a firewall needs to be configured for incoming Mosh UPD data (default port 60001)
sudo ufw allow 60001.
Connecting to my server
mosh email@example.com didn't work and the problem at this point was that my local shell was not sending a proper LANG environment variable for the host, leaving me with the following output:
~$ mosh firstname.lastname@example.org mosh-server needs a UTF-8 native locale to run. Unfortunately, the local environment (LC_CTYPE=) specifies the character set "ISO-8859-1", The client-supplied environment (LC_CTYPE=) specifies the character set "US-ASCII". LANG= LANGUAGE= LC_CTYPE= LC_NUMERIC="POSIX" LC_TIME="POSIX" LC_COLLATE="POSIX" LC_MONETARY="POSIX" LC_MESSAGES="POSIX" ACE [REPLACE ...]
I succeeded to fix that by configuring my local OSX machine (El Capitan on X220) LANG value and to pass it for the server.
~/.zshrc add line
export LANG="en_US.UTF-8" and to
/etc/ssh/ssh_config the following:
Host exampleserver HostName example.com SendEnv LANG
Reload your shell init file by
source ~/.zshrc (I use alias
rp for this).
On server side (Ubuntu 16.04 in this case) you need to receive the LANG from the client, which it does by default. In case of problems make sure that the file
/etc/ssh/ssh_config has the line
AcceptEnv LANG. In this case the default was
AcceptEnv LANG LC_* which works fine.