Connect to server.example using ~/.ssh/project_key.
The key has a non-default name, so specify it on the command line.
Which command is appropriate?
The OpenSSH client's -i option selects the private-key file. Protect that file on the client.
Detailed explanation
ssh -p ~/.ssh/project_key server.exampleIncorrect. -p selects a TCP port, not a key file.
ssh -k ~/.ssh/project_key server.exampleIncorrect. -k does not select the identity file in this command.
ssh -K ~/.ssh/project_key server.exampleIncorrect. -K is not the standard identity-file option.
ssh -i ~/.ssh/project_key server.exampleCorrect. ssh -i ~/.ssh/project_key server.example selects the specified key.
Try it yourself
An example you can run in a temporary verification environment.
ssh -G -i ~/.ssh/project_key server.example | grep '^identityfile'Expected result
接続せず、指定identity fileを含む設定を表示するKey points
- -i
- Private key
- Client side
Notes
- Environment: OpenSSH 9.x
- Use a disposable VM or test account when validating installation and SSH behavior.
- Exact command output can vary slightly by distribution and OpenSSH version.
Foundation review
Identify the scope
Port and other single-letter options can look similar, but they change different connection parameters.
Check the side effect
Check the resolved identity-file path and its permissions before attempting a real connection.