How to fix /home/user/.ssh/config: terminating, X bad configuration options in SSH

SSHINTERMEDIATEHIGHUpdated Sep 3, 2026· 287 views

SSH fails to connect or initialize when your .ssh/config file contains invalid or misspelled configuration options. This error occurs during SSH parsing and prevents any connections from being established.

Quick fix

Fixes /home/user/.ssh/config: terminating, X bad configuration options

ssh -G hostname
  1. Identify the problematic line
  2. Check option spelling and case sensitivity
  3. Resolve platform-specific options
  4. Check SSH version compatibility
ssh — error
ssh -G hostname
/home/user/.ssh/config: terminating, X bad configuration options

What this error means

OpenSSH has encountered one or more invalid configuration options in your ~/.ssh/config or /etc/ssh/sshd_config file. This happens when you use a misspelled option name, an option that doesn't exist in your SSH version, a platform-specific option on an incompatible system, or a deprecated option that has been removed from newer OpenSSH releases. The SSH service refuses to continue and terminates rather than apply an invalid configuration.

Typical symptoms

  • SSH connections fail with 'Bad configuration option' error message
  • The error message specifies which line number contains the problem
  • SSH client or sshd service refuses to start or accept connections
  • Git operations fail with SSH key exchange errors
  • Remote login attempts are rejected immediately

Common causes

  1. Typo in configuration option name (e.g., 'identifyfile' instead of 'IdentityFile')
  2. Using macOS-specific options like 'UseKeychain' on Linux systems
  3. Using options not supported by your OpenSSH version (e.g., ProxyJump on OpenSSH < 7.3)
  4. Deprecated options removed in newer OpenSSH versions (e.g., RSAAuthentication in OpenSSH 7.0+)
  5. Server-side options used in client config or vice versa
  6. File encoding issues such as BOM (Byte Order Mark) or CRLF line endings
  7. Copy-pasted configuration from incompatible documentation

How to fix "/home/user/.ssh/config: terminating, X bad configuration options"

1Identify the problematic line

Run this command to see which line has the bad option:

bash
ssh -G hostname

or for sshd config:

bash
sudo sshd -t

The output will specify the exact line number and option name causing the issue.

2Check option spelling and case sensitivity

SSH config options are case-sensitive. Common misspellings:
- 'identifyfile' should be 'IdentityFile'
- 'identitiesonly' should be 'IdentitiesOnly'
- 'hostkey' should be 'HostKey'
- 'port' should be 'Port'

Open your ~/.ssh/config file and verify the exact spelling matches the OpenSSH documentation.

3Resolve platform-specific options

If you're using a shared config across Linux and macOS:

For UseKeychain (macOS only):

bash
# Add IgnoreUnknown directive above the option
IgnoreUnknown UseKeychain
UseKeychain yes

This tells non-Apple SSH to ignore the option while macOS still uses it.

For other macOS-specific options, use the same pattern:

bash
IgnoreUnknown AddKeysToAgent,UseKeychain
AddKeysToAgent yes
UseKeychain yes
4Check SSH version compatibility

Some options require a minimum OpenSSH version:

bash
ssh -V

Common version requirements:
- 'ProxyJump' requires OpenSSH 7.3+
- 'PubkeyAcceptedAlgorithms' requires OpenSSH 7.8+
- 'Include' directive requires OpenSSH 7.3+

If your version is too old, either upgrade SSH or remove the unsupported option.

5Fix file encoding issues

SSH config files must use UTF-8 encoding with Unix line endings (LF, not CRLF).

In Vim:

vim
:set fileformat=unix    " Change CRLF to LF
:set nobomb             " Remove Byte Order Mark
:wq

On command line:

bash
# Convert CRLF to LF
dos2unix ~/.ssh/config

# Or with sed
sed -i 's/\r$//' ~/.ssh/config
6Remove or comment out deprecated options

Check the OpenSSH release notes and comment out any deprecated options. Common ones:

bash
# Deprecated in OpenSSH 7.0+ (use PubkeyAuthentication instead)
# RSAAuthentication yes

# Deprecated in OpenSSH 7.5+ (now the default)
# UsePrivilegeSeparation sandbox

# Deprecated in OpenSSH 7.4+
# GSSAPICleanupCredentials yes

You can find the current supported options with:

bash
man ssh_config
7Validate the config and reconnect

After making changes, verify the syntax:

bash
# For ~/.ssh/config
ssh -G hostname

# For /etc/ssh/sshd_config
sudo sshd -t

Both commands should exit with no output if the config is valid. Then test your connection:

bash
ssh -v hostname    # Use -v for verbose output to debug further

Advanced notes

Client vs Server Config: ~/.ssh/config is the client-side config and accepts client options only (IdentityFile, ProxyJump, etc.). /etc/ssh/sshd_config is the server-side config and accepts server options only (PermitRootLogin, PasswordAuthentication, etc.). Using the wrong options in the wrong file causes this error.

Backing up before changes: Always backup your config first:

bash
cp ~/.ssh/config ~/.ssh/config.backup-$(date +%Y%m%d)

Testing with verbose mode: Use ssh -vvv hostname to see detailed parsing and identify exactly where the error occurs.

Match blocks: If using 'Match' directives, ensure they're supported by your OpenSSH version (7.3+) and that the criteria are valid. Some criteria like 'exec' require careful escaping.

Frequently asked questions

What does "/home/user/.ssh/config: terminating, X bad configuration options" mean?
ssh/config or /etc/ssh/sshd_config file. This happens when you use a misspelled option name, an option that doesn't exist in your SSH version, a platform-specific option on an incompatible system, or a deprecated option that has been removed from newer OpenSSH releases. The SSH service refuses to continue and terminates rather than apply an invalid configuration.
How do I fix "/home/user/.ssh/config: terminating, X bad configuration options"?
SSH fails to connect or initialize when your .ssh/config file contains invalid or misspelled configuration options. This error occurs during SSH parsing and prevents any connections from being established.
What causes "/home/user/.ssh/config: terminating, X bad configuration options"?
Typo in configuration option name (e.g., 'identifyfile' instead of 'IdentityFile') Using macOS-specific options like 'UseKeychain' on Linux systems Using options not supported by your OpenSSH version (e.g., ProxyJump on OpenSSH < 7.3)
Is the "/home/user/.ssh/config: terminating, X bad configuration options" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading