Define alias prod in ~/.ssh/config.
ssh prod should connect to server.example.test as deploy on port 2222.
Which block is appropriate?
An SSH client config block uses Host for the alias, HostName for the real destination, and User and Port for connection parameters.
Detailed explanation
HostName prod
Host server.example.test
User deploy
Port 2222Incorrect. The Host and HostName directives are reversed.
Incorrect. The Host and HostName directives are reversed.
Host prod
Server server.example.test
Login deploy
Port 2222Incorrect. Server and Login are not the corresponding OpenSSH directives.
Incorrect. Server and Login are not the corresponding OpenSSH directives.
Host prod
HostName server.example.test
User deploy
Port 2222Correct. It maps prod to the real host, user, and port.
Correct. It maps prod to the real host, user, and port.
Alias prod = server.example.test
UserName deploy
SSHPort 2222Incorrect. It is not valid SSH client config syntax.
Incorrect. It is not valid SSH client config syntax.
Try it yourself
An example you can run in a temporary verification environment.
printf '%s
' 'Host prod' ' HostName server.example.test' ' User deploy' ' Port 2222'Expected result
Host prod
HostName server.example.test
User deploy
Port 2222Key points
- Host is the alias pattern
- HostName is the destination
- User and Port
Notes
- Environment: OpenSSH client config blockの表示のみ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.