温馨提示×

Linux SecureCRT怎么解决乱码

小樊
64
2026-08-06 01:19:05
栏目: 智能运维

在 Linux 下使用 SecureCRT 出现乱码,90% 是字符编码不一致导致的。下面按常见原因逐步排查解决。


一、先检查 SecureCRT 会话编码(最常见)

  1. 打开 SecureCRT
  2. 右键会话 → Session Options(会话选项)
  3. 找到:
    Terminal → Appearance → Character encoding
    
  4. 设置为:
    • UTF-8(首选)
    • 如果服务器是老系统,可尝试 GBK / GB2312

✅ 一般改完后 重新连接 即可。


二、确认 Linux 服务器字符集

在服务器上执行:

locale
echo $LANG

推荐输出类似:

LANG=en_US.UTF-8
or
LANG=zh_CN.UTF-8

如果不是 UTF-8,可临时修改:

export LANG=zh_CN.UTF-8

永久修改(谨慎):

# ~/.bashrc 或 ~/.bash_profile
export LANG=zh_CN.UTF-8
export LC_ALL=zh_CN.UTF-8

三、SecureCRT 字体问题

有时不是乱码,而是字体不支持中文。

  1. Session Options
  2. Terminal → Font
  3. 选择支持中文的字体:
    • Monospace
    • DejaVu Sans Mono
    • WenQuanYi Zen Hei

四、SSH 服务器端语言环境

如果服务器没有中文 locale:

locale -a | grep zh

如果没有,可安装:

  • Debian / Ubuntu
sudo apt install locales
sudo dpkg-reconfigure locales
  • CentOS / RHEL
sudo yum install langpacks-zh_CN

五、VI / VIM 中文显示乱码

如果 只有 vim 乱码

vim ~/.vimrc

添加:

set encoding=utf-8
set fileencodings=utf-8,gbk
set termencoding=utf-8

六、SecureCRT 高级选项(少见)

如果仍乱码:

  • Session Options → Terminal → Emulation
    • Terminal 类型:LinuxXterm
  • 关闭:
    • Use locale is not supported

七、快速排错口诀 ✅

SecureCRT 乱码 ≠ 服务器乱码
优先改:Session → Character encoding → UTF-8


如果你愿意,可以把以下信息发我,我可以一步到位帮你定位:

  • Linux 发行版
  • echo $LANG 输出
  • 文件名乱码 / vim 乱码 / ls 乱码 / 日志乱码 哪种?

我可以直接给你精确配置方案。

0