How to propagate your Editor, Language and other Choices to Remote Machines via SSH

We assume you use OpenSSH on server and client side. YMMV with other SSH implementations.

Preparations on the Server-Side

To allow users on to propagate environment variables when using SSH, the AcceptEnv directive must be used on the server-side

  • Add the following line to your sshd_config, located at /etc/ssh/sshd_config at least on Debian and Ubuntu based distributions: AcceptEnv EDITOR LANG LC_*
  • Either let the sshd reload its configuration or restart the sshd. On Debian based distributions /etc/init.d/ssh reload should suffice, but /etc/init.d/ssh restart works, too. On modern distributions, this does not kill currently used ssh connections.

Configuration on the Client-Side

  • Each user who wants to use these features should add the line SendEnv EDITOR LANG LC_* to his $HOME/.ssh/config file, either to the section of the host where he wants to propagate the environment variables or to the Host * section if the environment variables should be propagated to every host.
  • In case you haven't had a $HOME/.ssh/config file before, start with the following content saved at that location:
Host *
  SendEnv  EDITOR LANG LC_*

Other common Environment Variables to propagate via SSH

  • If you want automatically your name inserted as committer or author when using git under admin or root accounts, add GIT_* to the list of environment variables in both locations and set at least GIT_AUTHOR_NAME and GIT_AUTHOR_EMAIL apropriately, maybe also GIT_COMMITTER_NAME, GIT_COMMITTER_EMAIL and GIT_EDITOR.
  • If you want to use all of your terminal's features (like e.g. 256 color support) remotely, add the environment variable TERM to the lists above. But be careful if remote hosts don't know about your terminal's features, e.g. if you connect to some older machine with TERM set to xterm-256-color or so.