Configuring environment variables for mosh-server

For anybody using mosh to connect to a Clear Linux system, if you’ve looked at the mosh-server manpage and are trying to figure out where to set the environment variables MOSH_SERVER_NETWORK_TMOUT and MOSH_SERVER_SIGNAL_TMOUT:

  • The SSH connection initiated by a mosh client will likely not execute ~/.bashrc, ~/.bash_profile, etc. Discussion of this can be found elsewhere in this forum.
  • You can set the variables in ~/.ssh/environment, for example:
MOSH_SERVER_NETWORK_TMOUT=604800
MOSH_SERVER_SIGNAL_TMOUT=30
  • But, you will also need to configure sshd to allow reading that user environment file by adding this to /etc/ssh/sshd_config (man sshd_config for more info):
PermitUserEnvironment MOSH_SERVER_*
  • Remember that you don’t need to restart sshd since it’s socket-activated by default (systemd launches a fresh sshd on each new connection)