How to fix /home/user/.ssh/config: line X: Bad configuration option: in SSH

SSHBEGINNERMEDIUMUpdated Jan 4, 2026ยท 255 views

This error occurs when your SSH configuration file (~/.ssh/config) contains an unrecognized or unsupported option. It's typically caused by typos, unsupported options for your SSH version, or platform-specific settings used on an incompatible system.

Quick fix

Fixes /home/user/.ssh/config: line X: Bad configuration option:

/home/user/.ssh/config: line 42: Bad configuration option: UseKeychain
  1. Identify the exact line with the error
  2. Check for typos in the option name
  3. Check your OpenSSH version
  4. Remove platform-specific options on incompatible systems
ssh โ€” error
/home/user/.ssh/config: line 42: Bad configuration option: UseKeychain
/home/user/.ssh/config: line X: Bad configuration option:

What this error means

SSH reads your configuration file (~/.ssh/config) when establishing connections. If a configuration option is not recognized by your version of OpenSSH, SSH stops parsing and reports "Bad configuration option" with the line number. This happens during the config parsing phase, before any connection is attempted. The error message includes the line number where the problem was found, though sometimes it points to the following line, making it important to check context around the reported line.

Typical symptoms

  • SSH connections fail immediately with 'Bad configuration option' error
  • Error message shows a line number (e.g., 'line 42: Bad configuration option')
  • SSH commands like 'ssh user@host' fail before attempting connection
  • ssh -G hostname shows parsing error instead of config output
  • Error disappears when using -F /dev/null to skip config file
  • SSH works fine on another machine but fails on this one

Common causes

  1. Typo or misspelling in a configuration option (e.g., 'IdentiyFile' instead of 'IdentityFile')
  2. Using an unsupported option for your installed OpenSSH version (e.g., UseKeychain on Linux)
  3. Using options from macOS (UseKeychain, AddKeysToAgent) on Linux/Windows
  4. Case sensitivity issue (SSH config is case-sensitive for option names)
  5. Invisible or hidden characters in the config file (often from copy-pasting from websites)
  6. Option placed outside of a Host block when it should be inside one
  7. Syntax error like missing colon or incorrect value format
  8. Using an option that was deprecated or renamed in your SSH version

How to fix "/home/user/.ssh/config: line X: Bad configuration option:"

1Identify the exact line with the error

SSH will show the problematic line number in the error message. For example:

bash
/home/user/.ssh/config: line 42: Bad configuration option: UseKeychain

Open your config file and check line 42 (and the surrounding context):

bash
cat -n ~/.ssh/config | sed -n '40,45p'

This will show line numbers, making it easy to spot the problem.

2Check for typos in the option name

SSH configuration options are case-sensitive and must be spelled exactly right. Common misspellings:

| Wrong | Correct |
|-------|---------|
| IdentiyFile | IdentityFile |
| HostName | HostName (not Hostname) |
| ProxyJump | ProxyJump |
| StrictHostKeyChecking | StrictHostKeyChecking |
| AddKeysToAgent | AddKeysToAgent |
| ServerAliveInterval | ServerAliveInterval |

Review the exact spelling of every option. Use the official SSH documentation as a reference:

bash
man ssh_config
3Check your OpenSSH version

Some SSH options are only available in newer versions of OpenSSH. Check your version:

bash
ssh -V

This will show output like: OpenSSH_8.2p1 Ubuntu-4ubuntu0.5

Then check the OpenSSH release notes to see which version added the problematic option. For example:
- UseKeychain was added in OpenSSH 7.3 (macOS specific)
- AddKeysToAgent was added in OpenSSH 7.2
- IgnoreUnknown was added in OpenSSH 7.3

If you're using an older version and need a newer option, either upgrade OpenSSH or remove the unsupported option.

4Remove platform-specific options on incompatible systems

Some options only work on specific platforms:

UseKeychain - macOS only (not available on Linux/Windows)
ControlMaster, ControlPath, ControlPersist - Not supported on Windows native SSH

If you're on Linux/Windows and see these in your config, comment them out or remove them:

ssh
# For macOS only:
# UseKeychain yes
# AddKeysToAgent yes

Host example.com
    HostName example.com
    User myuser
    IdentityFile ~/.ssh/id_rsa

If you need different configs for macOS vs Linux, consider using the IgnoreUnknown directive at the top of your config to suppress warnings about unsupported options.

5Use IgnoreUnknown for cross-platform compatibility

If you maintain a config file across multiple systems (macOS, Linux, Windows), use IgnoreUnknown to ignore unsupported options instead of having them cause errors:

ssh
# At the top of ~/.ssh/config
IgnoreUnknown UseKeychain,AddKeysToAgent

# Now these won't cause errors on non-macOS systems
Host example.com
    HostName example.com
    User myuser
    UseKeychain yes
    AddKeysToAgent yes
    IdentityFile ~/.ssh/id_rsa

The listed options will be silently ignored on systems that don't support them.

6Check for hidden characters or encoding issues

Sometimes copy-pasting from websites or documents introduces hidden Unicode characters or mixed line endings. Check your file:

bash
# Show hidden characters and line endings
cat -A ~/.ssh/config | sed -n '40,45p'

Lines ending with $ (Unix/Linux) are correct. Lines ending with ^M$ indicate Windows-style line endings (CRLF), which can cause parsing issues.

Fix line endings if needed:

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

# Or using sed
sed -i 's/\r$//' ~/.ssh/config

If you suspect encoding issues, you can also recreate the problematic lines manually instead of copy-pasting.

7Validate your config file syntax

Test your SSH config without making a connection using ssh -G:

bash
ssh -G example.com

If your config is valid, this will output the effective configuration for that host. If there are parsing errors, SSH will report them with the line number.

Another validation method:

bash
# This will fail if config is invalid
ssh -T -F ~/.ssh/config example.com

Once the config is valid, ssh will attempt the connection (and may fail for other reasons, but parsing errors are gone).

8Check the SSH manual for valid options

Review the complete list of valid SSH configuration options:

bash
man ssh_config

This shows all available options, their syntax, and which versions of OpenSSH support them. Pay special attention to:
- Case sensitivity requirements
- Valid values (e.g., yes/no vs true/false)
- Host block vs global scope requirements

Some options only work inside Host blocks, not at the top level of the config file. For example:

ssh
# WRONG: Global level
IdentityFile ~/.ssh/id_rsa

# CORRECT: Inside Host block
Host example.com
    IdentityFile ~/.ssh/id_rsa

Advanced notes

Advanced troubleshooting:

Version-specific options: Different OpenSSH versions support different options. Use ssh -V to check your version and cross-reference the man pages for that version. For example, OpenSSH 8.8+ changed some behavior around public key authentication.

Distribution-specific patches: Some Linux distributions (Ubuntu, Fedora, CentOS) apply custom patches to OpenSSH that add or remove options. Check your distribution's OpenSSH documentation if an option seems valid but doesn't work.

SSH Agent integration: The AddKeysToAgent and IdentitiesOnly options interact with ssh-agent in complex ways. If using these, ensure your SSH agent is running (eval $(ssh-agent)) and keys are properly loaded (ssh-add ~/.ssh/id_rsa).

ProxyJump vs ProxyCommand: Older OpenSSH versions don't support ProxyJump. Use ProxyCommand instead:

ssh
# Modern (7.3+):
ProxyJump jumphost.com

# Fallback for older versions:
ProxyCommand ssh -W %h:%p jumphost.com

Windows OpenSSH: Windows 10+ includes built-in OpenSSH, but it's often outdated. Use ssh -V and consider upgrading or using git-bash/WSL for newer OpenSSH versions with more options.

Frequently asked questions

What does "/home/user/.ssh/config: line X: Bad configuration option:" mean?
ssh/config) when establishing connections. If a configuration option is not recognized by your version of OpenSSH, SSH stops parsing and reports "Bad configuration option" with the line number. This happens during the config parsing phase, before any connection is attempted.
How do I fix "/home/user/.ssh/config: line X: Bad configuration option:"?
This error occurs when your SSH configuration file (~/.ssh/config) contains an unrecognized or unsupported option. It's typically caused by typos, unsupported options for your SSH version, or platform-specific settings used on an incompatible system.
What causes "/home/user/.ssh/config: line X: Bad configuration option:"?
Typo or misspelling in a configuration option (e.g., 'IdentiyFile' instead of 'IdentityFile') Using an unsupported option for your installed OpenSSH version (e.g., UseKeychain on Linux) Using options from macOS (UseKeychain, AddKeysToAgent) on Linux/Windows
Is the "/home/user/.ssh/config: line X: Bad configuration option:" error serious?
It is a medium-severity error โ€” more of a blocker than a risk. The steps above resolve it.

Official resources & further reading