Ray Mendis

Fixing SSH Locale Warnings on macOS / Debian

. The Problem

When connecting to a Linux VPS (Debian/Ubuntu) via SSH from a macOS Terminal, the following warning repeatedly appears upon login:

-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory
-bash: warning: setlocale: LC_CTYPE: cannot change locale (UTF-8): No such file or directory

Why it happens:

2. The Solution

To fix this, we have to stop macOS from aggressively pushing incomplete locale environment variables through the SSH connection.

Step-by-Step Resolution:

  1. Disconnect from the remote VPS server.
  2. Open the macOS Terminal app locally.
  3. In the top macOS menu bar, navigate to Terminal > Settings… (or Preferences… on older macOS versions).
  4. Click on the Profiles tab at the top of the settings window.
  5. Select the Advanced sub-tab on the far right.
  6. Locate the checkbox labeled: “Set locale environment variables on startup”.
  7. Uncheck this box.
  8. Restart the Terminal application and reconnect to the VPS.

3. The Result

Executed Commands

1. Commands Run on the VPS (Debian Server)

Before adjusting the Mac settings, I verified and updated the server’s supported language packs so it could properly recognise German character mapping. My Macbook has a German keyboard, therefore when I connect over ssh to my VPS, I need to tell my VPS that I am loging in with a German keyboard.

Purpose: This opens an interactive menu to install specific language environments (like de_DE.UTF-8 and en_US.UTF-8) directly onto the Debian system operating system.

2. Commands for the Local Machine (Macbook Pro)

While I ultimately fixed the issue using the macOS Terminal GUI settings, the core configuration file that controls how SSH handles these environment variables on Unix-based clients, I also needed to update the same setting on my Macbook.

To edit the global SSH client configuration:

Step-by-Step Resolution:

  1. Disconnect from the remote VPS server.
  2. Open the macOS Terminal app locally.
  3. In the top macOS menu bar, navigate to Terminal > Settings… (or Preferences… on older macOS versions).
  4. Click on the Profiles tab at the top of the settings window.
  5. Select the Advanced sub-tab on the far right.
  6. Locate the checkbox labeled: “Set locale environment variables on startup”.
  7. Uncheck this box.
  8. Restart the Terminal application and reconnect to the VPS.
Exit mobile version