ssh远程到服务器后,遇到中文乱码,建议通过locale检查当前的字符集,如果遇到LC_ALL=无值,十有八九是要出问题的。
此时可以通过执行export LC_ALL=zh_CN.UTF-8临时解决。
当然,把上面这句添加到.bash_profile中,就可以永久解决了。 就像这样

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
export LC_ALL=zh_CN.UTF-8

补充一点,用en_US.UTF-8代替上文的zh_CN.UTF-8也是同样有效的。