How do I inspect a saved SSH known-host entry?
Use ssh-keygen -F to find the stored host record. It understands hashed hostnames, so searching the file as ordinary text can miss a valid entry. Inspect the record before deciding that any host-key change needs remediation.
Instructions
1. Search the exact connection name
Use the hostname or IP you entered in the SSH command. A hostname and an IP can have separate saved records.
ssh-keygen -F vps.example.com -f "$env:USERPROFILE\.ssh\known_hosts"The output identifies matching record lines. It reads the file without changing it.
2. Include the port when it is nondefault
The bracketed hostname-and-port form identifies a record for a custom SSH port.
ssh-keygen -F "[vps.example.com]:2222" -f "$env:USERPROFILE\.ssh\known_hosts"Replace 2222 with the assigned port. Brackets are part of the lookup key.
3. Check which known-host file is in use
If a custom configuration points to another file, inspect the effective configuration. Do not remove records from a file that the connection is not using.
ssh -G vps.example.com | Select-String -Pattern "userknownhostsfile|hostname|port"This displays resolved connection settings without opening a network session.
Check the result
- The searched record corresponds to the exact hostname and port you use.
- The known-host file matches the effective client configuration.
Troubleshooting
- No entry is found
- Check for a different alias, port, Windows profile or custom known-host file.
- The hostname is hashed
- That is supported by -F; it is not a reason to delete the entire file.
Official references
Use the documentation for your installed version when a flag, service name or platform feature differs.
