Fix Garbled Characters in PuTTY SSH

Solve encoding issues and display text correctly in your terminal

Why SSH Output Shows Gibberish

Garbled characters (often called "mojibake" or "乱码" in Chinese) appear when there's a mismatch between:

  • The character encoding PuTTY expects
  • The character encoding the server sends
  • The locale settings on the remote system
  • The font used in PuTTY

Common Symptoms:

  • Chinese, Japanese, or Korean characters appear as ??? or boxes
  • Accented characters (é, ñ, ü) display incorrectly
  • Special symbols show as random characters
  • File names with non-ASCII characters look corrupted
  • Man pages or documentation appears unreadable

Common Causes

1. Mismatched Character Encoding

  • PuTTY uses: ISO-8859-1 (Latin-1) by default
  • Most modern systems use: UTF-8
  • Result: Multi-byte characters display incorrectly

2. Server Locale Issues

  • Server locale not set correctly
  • Terminal type not properly configured
  • LANG environment variable misconfigured

3. Font Limitations

  • Font doesn't include required character glyphs
  • Fixed-width font missing Unicode support
  • Font size affecting character rendering

Solution 1: Change PuTTY Character Set (Primary Fix)

✓ This fixes 90% of garbled character issues!

Steps:

  1. Open PuTTY Configuration
    • Launch putty.exe
    • Load your saved session (if applicable)
  2. Navigate to Translation Settings:
    • In the left panel: Window → Translation
  3. Change Character Set:
    • Find "Remote character set" dropdown
    • Change from "ISO-8859-1:1998 (Latin-1, West Europe)" to:
    • "UTF-8" ← Select this
  4. Save Your Session:
    • Go back to Session category
    • Click "Save"
  5. Connect and Test:
    • Click "Open"
    • Characters should now display correctly

Solution 2: Adjust Server Locale

Check Current Locale

# Check current locale settings
$ locale

# You should see UTF-8 in the output
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8

Fix Locale on Ubuntu/Debian

# Generate UTF-8 locales
$ sudo locale-gen en_US.UTF-8

# Update locale
$ sudo update-locale LANG=en_US.UTF-8

# For Chinese (Simplified)
$ sudo locale-gen zh_CN.UTF-8

# For Chinese (Traditional)
$ sudo locale-gen zh_TW.UTF-8

# Apply changes (logout and login, or run)
$ source /etc/default/locale

Fix Locale on CentOS/RHEL

# Set system locale
$ sudo localectl set-locale LANG=en_US.UTF-8

# Verify
$ localectl status

Temporary Fix (Current Session Only)

# Set for current session
$ export LANG=en_US.UTF-8
$ export LC_ALL=en_US.UTF-8

# Add to ~/.bashrc or ~/.zshrc for persistence
$ echo 'export LANG=en_US.UTF-8' >> ~/.bashrc
$ echo 'export LC_ALL=en_US.UTF-8' >> ~/.bashrc

Solution 3: Change PuTTY Font

Recommended Fonts for Unicode:

  1. Navigate to Appearance:
    • In PuTTY config: Window → Appearance
  2. Click "Change" for Font:
    • Try these Unicode-capable fonts:
Font NameBest For
ConsolasGeneral use, good Unicode support
Lucida ConsoleWider character support
DejaVu Sans MonoExcellent Unicode coverage
Cascadia CodeModern, comprehensive Unicode
Source Code ProClean, wide language support
  1. Select a font and click OK
  2. Save your session

Solution 4: Install Language Support

For Chinese Characters

# Ubuntu/Debian
$ sudo apt-get install language-pack-zh-hans
$ sudo apt-get install fonts-wqy-microhei fonts-wqy-zenhei

# CentOS/RHEL
$ sudo yum install glibc-langpack-zh
$ sudo yum groupinstall "Chinese Support"

For Japanese Characters

# Ubuntu/Debian
$ sudo apt-get install language-pack-ja
$ sudo apt-get install fonts-ipafont fonts-ipaexfont

For Korean Characters

# Ubuntu/Debian
$ sudo apt-get install language-pack-ko
$ sudo apt-get install fonts-nanum fonts-nanum-coding

Example Fix Walkthrough

Scenario: Chinese File Names Display as ????

Step 1: PuTTY Configuration

  1. Window → Translation → Remote character set: UTF-8
  2. Window → Appearance → Change font to: Consolas or Lucida Console
  3. Save session

Step 2: Server Configuration

# SSH into server
$ ssh user@server

# Check current locale
$ locale
# If not UTF-8, fix it:

$ sudo locale-gen zh_CN.UTF-8
$ export LANG=zh_CN.UTF-8
$ export LC_ALL=zh_CN.UTF-8

# Add to ~/.bashrc for permanence
$ echo 'export LANG=zh_CN.UTF-8' >> ~/.bashrc

Step 3: Test

# Create test file with Chinese name
$ touch 测试文件.txt

# List files
$ ls -la

# Should display correctly now!

Troubleshooting

Still Showing Boxes or Question Marks

Try this checklist:

  1. ✓ PuTTY character set is UTF-8
  2. ✓ Server locale is UTF-8 (locale command)
  3. ✓ Font supports the characters (try DejaVu Sans Mono)
  4. ✓ Reconnect after changing settings
  5. ✓ Language packs installed on server

Characters Correct in vim but Wrong in Terminal

Solution:

  • vim may have its own encoding settings
  • Check :set encoding in vim
  • Add to ~/.vimrc: set encoding=utf-8
  • Also add: set fileencoding=utf-8

Some Characters Display, Others Don't

Cause: Font doesn't have glyphs for all Unicode characters

Solution:

  1. Install a comprehensive Unicode font on Windows
  2. Try DejaVu Sans Mono (most comprehensive)
  3. Or use Windows Terminal instead of PuTTY for better Unicode support

Man Pages Still Garbled

# Man pages use specific encoding
# Set environment variable
$ export LESSCHARSET=utf-8

# Add to ~/.bashrc
$ echo 'export LESSCHARSET=utf-8' >> ~/.bashrc

# Test
$ man ls

Final Checklist

Configuration Checklist:

  • ☐ PuTTY → Window → Translation: UTF-8
  • ☐ PuTTY → Window → Appearance: Unicode font (Consolas, DejaVu)
  • ☐ Server: locale shows UTF-8
  • ☐ Server: echo $LANG shows .UTF-8
  • ☐ Server: Language packs installed
  • ☐ Shell config (~/.bashrc): LANG and LC_ALL set to UTF-8
  • ☐ Reconnect after all changes

Prevention Tips

  • Always use UTF-8: It's the universal standard
  • Set default PuTTY session: Configure "Default Settings" with UTF-8
  • Server templates: Include locale settings in server provisioning scripts
  • Document font requirements: Note which fonts work for your languages
  • Test with sample text: Keep test files with various characters

Alternative Solutions

Use Modern SSH Clients

Consider these alternatives with better Unicode support:

  • Windows Terminal: Native UTF-8 support, modern UI
  • MobaXterm: Excellent Unicode handling, X11 support
  • Termius: Cross-platform, cloud sync
  • WSL2 + Terminal: Full Linux environment on Windows

Related Resources

;