A client has several private keys and must connect to app.example.test using a specified key.
Which command is appropriate?
ssh -i identity_file selects the private key used for a connection.
Detailed explanation
ssh -k ~/.ssh/app_ed25519 trainee@app.example.testIncorrect. -k disables GSSAPI credential delegation; it does not select a key file.
ssh -K ~/.ssh/app_ed25519 trainee@app.example.testIncorrect. -K is not the general option for specifying an SSH key file.
ssh-keygen -i ~/.ssh/app_ed25519 trainee@app.example.testIncorrect. ssh-keygen -i converts an external key format and does not connect to a host.
ssh -i ~/.ssh/app_ed25519 trainee@app.example.testCorrect. -i specifies the private key file for this connection.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s\n' 'ssh -i ~/.ssh/app_ed25519 trainee@app.example.test'Expected result
ssh -i ~/.ssh/app_ed25519 trainee@app.example.testKey points
- ssh -i
- identity file
- Connection versus key generation
Notes
- Environment: OpenSSH clientのオプション確認
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Host key
A server identity key used by SSH clients to detect a changed endpoint.
User key
A key pair used to authenticate a user to an SSH server.
Port forwarding
An SSH tunnel that carries traffic between a local, remote, or dynamic endpoint.