nerdexam
Linux_Foundation

LFCS · 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 to an SSH server listening on a non-standard TCP port, the ssh client command can use either the -p option followed by the port number or the -o option to specify the Port configuration directive.

Submitted by yuriko_h· Apr 18, 2026Networking

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

(38 responses)
  • A
    3% (1)
  • B
    95% (36)
  • D
    3% (1)

Why each option

To connect to an SSH server listening on a non-standard TCP port, the ssh client command can use either the -p option followed by the port number or the -o option to specify the Port configuration directive.

Assh --port 2222 example.com

The --port option is not a standard or recognized command-line argument for the ssh client; the correct option for specifying the port is -p.

Bssh -p 2222 example.comCorrect

The -p option is a common and concise way to specify the port number for an SSH connection, directly telling the ssh client to connect to example.com on TCP port 2222 instead of the default port 22. This is a frequently used shortcut for specifying the Port configuration.

Cssh -o Port=2222 example.comCorrect

The -o option allows specifying any configuration option from the ssh_config man page directly on the command line, overriding values in configuration files. Using -o Port=2222 explicitly sets the target port for the SSH connection to 2222, providing an alternative to the -p option.

Dssh -o GatewayPort=2222 example.com

The -o GatewayPort option is an SSH client configuration directive used to specify whether the gateway should be bound to a non-privileged port, which is unrelated to specifying the destination port for the primary SSH connection.

Essh example.com:2222

Specifying the port with a colon directly after the hostname (example.com:2222) is not a valid syntax for the standard ssh command; this format is more commonly seen with tools like scp, rsync, or web URLs.

Concept tested: SSH custom port connection

Source: https://man7.org/linux/man-pages/man1/ssh.1.html

Topics

#ssh#remote connection#port specification#command options

Community Discussion

No community discussion yet for this question.

Full LFCS Practice