How to fix unknown option -- in SSH
SSH unknown option errors occur when an invalid or mistyped command-line flag is passed to the ssh command. This commonly happens due to typos, using double-dashes instead of single-dashes, or trying to use options that don't exist in your SSH version.
Quick fix
Fixes unknown option --
# WRONG - typos in option
ssh -prot 22 user@host.example.com
ssh -kep ~/.ssh/id_rsa user@host.example.com
# CORRECT - proper option names
ssh -p 22 user@host.example.com
ssh -i ~/.ssh/id_rsa user@host.example.com- Check your SSH command for typos
- Use single-dashes for short options
- Verify option syntax with ssh --help
- Check for version-specific options
# WRONG - typos in optionssh -prot 22 user@host.example.comssh -kep ~/.ssh/id_rsa user@host.example.com# CORRECT - proper option namesssh -p 22 user@host.example.comssh -i ~/.ssh/id_rsa user@host.example.comunknown option --
What this error means
The SSH client strictly validates all command-line options before attempting to connect. When you pass an unrecognized flag (like a typo or a non-existent option), SSH immediately returns an "unknown option" error and exits without trying to connect. The error message typically includes the problematic option to help you identify the issue. Unlike some command-line tools that accept double-dash options (--), SSH uses single-dash options exclusively.
Typical symptoms
- SSH command fails immediately with 'unknown option --' message
- Error appears before any connection attempt is made
- Works on one system but fails on another (version difference)
- Similar command worked in the past but now fails
- Error specifies the exact option that caused the problem
Common causes
- Typo in option name (e.g., -prot instead of -p, -kep instead of -i)
- Using double-dashes (--) instead of single-dash (-) for short options
- Option doesn't exist in your current SSH version
- Using scp or sftp option with ssh command (e.g., -P for port instead of -p)
- Extra spaces or special characters in the option
- Old config file containing deprecated SSH options
- Option syntax is wrong (e.g., -p port 22 instead of -p 22)
How to fix "unknown option --"
Review the exact command you're running and look for misspelled options:
# WRONG - typos in option
ssh -prot 22 user@host.example.com
ssh -kep ~/.ssh/id_rsa user@host.example.com
# CORRECT - proper option names
ssh -p 22 user@host.example.com
ssh -i ~/.ssh/id_rsa user@host.example.comCommon typos:
- -prot should be -p (port)
- -kep or -key should be -i (identity file)
- -usr should be -l (login username)
- -hosy should be understood as hostname (not an option)
SSH options must use a single dash (-), not double-dashes (--):
# WRONG - double-dashes not supported by ssh
ssh --port 22 user@host.example.com
ssh --identity ~/.ssh/id_rsa user@host.example.com
# CORRECT - single dash
ssh -p 22 user@host.example.com
ssh -i ~/.ssh/id_rsa user@host.example.comSSH does not support GNU-style long options. Some tools support both -p and --port, but SSH only accepts the short form.
Check what options are available in your SSH version:
ssh --helpOr view the full manual:
man sshLook for your option in the list. If it doesn't appear, either:
1. You have a typo
2. The option doesn't exist in your SSH version
3. You're using the wrong command (scp, sftp, ssh-keygen, etc.)
Some SSH options are only available in newer versions of OpenSSH. Check your version:
ssh -VIf you're trying to use an option that requires a newer version:
- Upgrade OpenSSH if possible
- Or use the -o option with the older equivalent:
# Instead of: ssh -J jumphost user@target
# On older SSH: ssh -o ProxyCommand="ssh -W %h:%p jumphost" user@targetDifferent SSH tools use different options. A common mistake:
# WRONG - scp uses -P (capital) for port, not -p
ssh -P 2222 user@host.example.com
scp -p file.txt user@host.example.com # -p means preserve permissions
# CORRECT - ssh uses -p (lowercase) for port
ssh -p 2222 user@host.example.com
# CORRECT - scp uses -P (capital) for port
scp -P 2222 file.txt user@host.example.comRemember:
- ssh uses lowercase -p for port
- scp and sftp use uppercase -P for port
If you're connecting without explicit options, check your config files:
cat ~/.ssh/config
cat /etc/ssh/ssh_configRemove any deprecated or invalid options. Example:
# BAD - unknown options
Host myhost
Hostname host.example.com
User ubuntu
IdentityFile ~/.ssh/id_rsa
UnknownOption value
# GOOD - only valid options
Host myhost
Hostname host.example.com
User ubuntu
IdentityFile ~/.ssh/id_rsa
Port 22
StrictHostKeyChecking accept-newIf you need to pass options that might not be recognized, use the -o flag to test:
# -o allows passing options in config file format
ssh -o "Port=2222" user@host.example.com
ssh -o "IdentityFile=~/.ssh/id_rsa" user@host.example.com
# Multiple -o flags work too
ssh -o "Port=2222" -o "StrictHostKeyChecking=no" user@host.example.comThis way, if the option is invalid, you get a clearer error message from the config parser rather than the command-line parser.
Advanced notes
Advanced troubleshooting:
SSH Config File Format vs Command Line: SSH config files use a different syntax than command-line options. Config files use Port 22 while command line uses -p 22. Common mistake: using --Port 22 on the command line (wrong).
Case Sensitivity: SSH options are case-sensitive on the command line. -P (uppercase) is different from -p (lowercase). However, in SSH config files, option names are case-insensitive.
Option Order Matters for Some Tools: While ssh is generally flexible about option order, some SSH wrappers or scripts may require options before the hostname. Try moving options to the front if you get unexpected errors.
Escaping in Scripts: If running SSH from scripts (bash, Python, etc.), be careful with shell escaping. Quotes and special characters can affect how options are parsed:
# In bash script - careful with quotes
ssh -i "~/.ssh/id_rsa" user@host # May not expand ~
ssh -i "$HOME/.ssh/id_rsa" user@host # Better - expands variableEnvironment Variables: Some SSH behavior can be controlled via environment variables instead of command-line options. Check man ssh_config for options that can also be set in config files.
Frequently asked questions
- What does "unknown option --" mean?
- The SSH client strictly validates all command-line options before attempting to connect. When you pass an unrecognized flag (like a typo or a non-existent option), SSH immediately returns an "unknown option" error and exits without trying to connect. The error message typically includes the problematic option to help you identify the issue.
- How do I fix "unknown option --"?
- SSH unknown option errors occur when an invalid or mistyped command-line flag is passed to the ssh command. This commonly happens due to typos, using double-dashes instead of single-dashes, or trying to use options that don't exist in your SSH version.
- What causes "unknown option --"?
- Typo in option name (e.g., -prot instead of -p, -kep instead of -i) Using double-dashes (--) instead of single-dash (-) for short options Option doesn't exist in your current SSH version
- Is the "unknown option --" error serious?
- It is a low-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐SSH Official Documentation
- ๐OpenSSH Manual: ssh(1) - Man Page (OpenBSD)(Official Docs)
- ๐Linux man-pages: ssh(1) - Secure Shell(Official Docs)