nerdexam
CompTIA

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.

Networking Fundamentals

Question

Which of the following commands connects to the remote host example.com which has OpenSSH listening on TCP port 2222? (Choose TWO correct answers.)

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)
  • A
    7% (3)
  • B
    71% (30)
  • D
    5% (2)
  • E
    17% (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.

Assh --port 2222 example.com

`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.

Bssh -p 2222 example.comCorrect

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.

Cssh -o Port=2222 example.comCorrect

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.

Dssh -o GatewayPort=2222 example.com

`GatewayPort` is an SSH configuration option related to SSH gateways, not for specifying the direct connection port to the target host.

Essh example.com:2222

`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

#SSH client#SSH port#remote connection#command line options

Community Discussion

No community discussion yet for this question.

Full LX0-104 Practice