The remote host doesn’t know that your terminal is using UTF-8.
By default, Terminal encodes text as UTF-8, and by default Terminal communicates this to the terminal shell via the LANG
environment variable (as long as you haven’t changed these preference settings).
You can see the encoding (and language) being used with the command locale
. For example, this is what it says on my Mac:
$ locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL=
If you run it locally and on the remote host you should see that the remote host doesn’t include “utf-8” in the locale values.
However, prior to Mac OS X Lion 10.7, by default ssh doesn’t communicate the LANG
environment variable to the remote host. You can arrange for this, but it requires configuring both the ssh client on your Mac to send the LANG
variable and the sshd daemon on the remote host to read it.
See the ssh_config and sshd_config man pages on the Mac and the remote host for details. You will probably add a line like SendEnv LANG LC_*
to the /etc/ssh/ssh_config
file on your Mac and AcceptEnv LANG LC_*
in /etc/ssh/sshd_config
on the remote host (the details may vary on the remote host).
Alternatively, you can simply export LANG="en_US.UTF-8"
once you log in to the remote shell (the exact syntax depends on the remote shell you’re using). Be sure to use the correct language if it isn’t US English (“en_US”). You may also automate this by setting LANG
from within a shell startup script like ~/.bash_profile
on the remote host.