How do I choose a particular private key when connecting?
Pass the private-key filename to -i and use IdentitiesOnly=yes to avoid offering unrelated agent keys. The corresponding public key must already be authorised for the remote account. Selecting a key cannot grant privileges that the account does not have.
Instructions
1. Identify the matching public-key fingerprint
Inspect the public file beside the private key. Keep private-key contents out of screenshots, chat and server uploads.
ssh-keygen -lf "$env:USERPROFILE\.ssh\server_ed25519.pub"Compare this fingerprint with the key enrolled for the intended server account.
2. Connect with the explicit identity
Use the filename without .pub as the private identity. Quote the full path so spaces remain one argument.
ssh -o IdentitiesOnly=yes -i "$env:USERPROFILE\.ssh\server_ed25519" adminuser@203.0.113.10The options select the local private key and limit offered identities. An encrypted key can still prompt for its passphrase.
3. Confirm the account and keep the key local
After login, check whoami. A successful key exchange proves acceptance for this account; it does not prove the same key is authorised for another username or another server.
Check the result
- The selected public-key fingerprint matches the enrolled key.
- SSH opens the intended account without offering a series of unrelated identities.
Troubleshooting
- Identity file is not accessible
- Check the exact local path and file access permissions.
- The selected key is rejected
- Confirm the remote username and enrolled public key. Repeatedly generating new keys will not repair a mismatched account.
Official references
Use the documentation for your installed version when a flag, service name or platform feature differs.
