LX0-104 · Question #14
Which of the following commands connects to the remote host example.com which has OpenSSH listening on TCP port 2222? (Choose TWO correct answers.)
The correct answer is B. ssh -p 2222 example.com C. ssh -o Port=2222 example.com. To connect via SSH to a non-standard port, the -p option or the -o Port= configuration option can be used.
Question
Options
- Assh --port 2222 example.com
- Bssh -p 2222 example.com
- Cssh -o Port=2222 example.com
- Dssh -o GatewayPort=2222 example.com
- Essh example.com:2222
How the community answered
(42 responses)- A7% (3)
- B71% (30)
- D5% (2)
- E17% (7)
Why each option
To connect via SSH to a non-standard port, the `-p` option or the `-o Port=` configuration option can be used.
`ssh --port` is not a valid command-line option for specifying the port in OpenSSH; the correct long option equivalent does not exist in this format.
The `ssh -p` option is the standard and most direct way to specify the port number for an SSH connection, overriding the default port 22.
The `ssh -o` option allows passing configuration directives directly on the command line, and `Port=2222` explicitly sets the connection port. This achieves the same result as `-p`, but uses the configuration file syntax.
`GatewayPort` is an SSH configuration option related to SSH gateways, not for specifying the direct connection port to the target host.
`ssh example.com:2222` is not the correct syntax for specifying a port with the `ssh` command; this syntax is sometimes used with other tools like `scp` or `rsync` for file paths, but not for the SSH port itself.
Concept tested: SSH custom port connection
Source: https://man7.org/linux/man-pages/man1/ssh.1.html
Topics
Community Discussion
No community discussion yet for this question.