SSH throws a 'missing argument' error when a command-line option or config file keyword doesn't have its required value. This typically happens with flags like -p, -i, or -o that expect arguments, or with malformed SSH config files.
The 'missing argument' error means SSH encountered an option or keyword that requires a value but none was provided, or the value format is incorrect. This can occur in two contexts: (1) when using SSH command-line flags that need arguments (like -p for port or -i for identity file), or (2) when the ~/.ssh/config file has syntax errors where keywords lack their required parameters.
Review the command for any options that lack values. Common options requiring arguments:
# Wrong - missing value
ssh -p user@hostname
ssh -i user@hostname
ssh -o PubkeyAuthentication user@hostname
# Correct - with values
ssh -p 2222 user@hostname
ssh -i ~/.ssh/my_key user@hostname
ssh -o PubkeyAuthentication=yes user@hostnameEnsure all flags have their required arguments provided.
When using SSH options with -o, use an equals sign (=) between the option and value, or wrap the entire option-value pair in quotes:
# Recommended - with equals sign
ssh -o BatchMode=yes user@hostname
ssh -o ConnectTimeout=10 user@hostname
# Alternative - with quotes
ssh -o 'BatchMode yes' user@hostname
# Wrong - space without quotes
ssh -o BatchMode yes user@hostname # Error: missing argumentIf you see an error with a specific line number in ~/.ssh/config, open the file and check that line:
vim ~/.ssh/config
# or
cat ~/.ssh/configCommon config errors:
# Wrong
Host # Missing pattern argument
LocalForward 8888:localhost:9999 # Wrong syntax
IdentityFile ~/.ssh/id_rsa # Multiple spaces (may cause issues)
# Correct
Host github.com
LocalForward 8888 localhost:9999
IdentityFile ~/.ssh/id_rsaSSH config parsing can fail if the file has wrong line endings or a BOM marker. Check this in vim:
vim ~/.ssh/config
# Inside vim, check line endings:
:set fileformat?
# If output is 'fileformat=dos', change it:
:set fileformat=unix
# Check for BOM:
:set bomb?
# If output shows 'bomb', remove it:
:set nobomb
# Save and exit
:wqAfter making fixes, validate the configuration by attempting a test connection:
# Test basic SSH connectivity
ssh -T [email protected]
# Test with verbose output to see which config is applied
ssh -T -v [email protected]
# Check if config file is valid without connecting
# (Some SSH versions support this)
ssh -G [email protected] | head -5Verbose output (-v) will show you exactly which configuration options are being loaded and where the error occurs.
SSH Option Styles: Some tools generate SSH commands with inconsistent option styles. The safest approach is always using -o name=value format. Some older SSH implementations may require quotes around options: -o 'name value'. Config File Precedence: SSH reads both /etc/ssh/ssh_config (system-wide) and ~/.ssh/config (user-specific). Check both files if experiencing unexpected errors. IDE and Tool Integration: VS Code, GitHub Copilot, and other tools that auto-generate SSH configs sometimes produce malformed syntax. Manual validation of auto-generated config files is recommended. Boolean Options: Options that accept yes/no values are strict about syntax - use -o 'OptionName=yes' or -o 'OptionName no' with proper spacing or equals signs.
Load key "/home/user/.ssh/id_rsa": invalid format
How to fix 'Load key invalid format' in SSH
Bad owner or permissions on /home/user/.ssh/config
How to fix "Bad owner or permissions on .ssh/config" in SSH
Error connecting to agent: Connection refused
How to fix "Error connecting to agent: Connection refused" in SSH
Connection closed by UNKNOWN port 65535
How to fix 'Connection closed by UNKNOWN port 65535' in SSH
Offending ECDSA key in /home/user/.ssh/known_hosts:line
How to fix "Offending ECDSA key in known_hosts" in SSH