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

A.

ssh --port 2222 example.com

B.

ssh -p 2222 example.com

C.

ssh -o Port=2222 example.com

D.

ssh -o GatewayPort=2222 example.com

E.

ssh example.com:2222

題解

「ssh」指令用來登入遠端的 SSH 伺服器。

選項 A,「ssh」指令沒有「--port」參數。

選項 B,「ssh」指令加上「-p」參數可以指定登入時用的連接埠。為正確答案。

選項 C,「ssh」指令加上「-o」參數可以設定許多選項,其中的「Port」選項用來設定登入時用的連接埠。為正確答案。

選項 D,「ssh」指令加上「-o」參數可以設定許多選項,但並沒有「GatewayPort」選項,相近的「GatewayPorts」選項是用來決定是否允許遠端主機連接本地轉送的連接埠,值為 yes 或 no,無法用來指定連線的連接埠。

選項 E,錯誤的「ssh」指令用法。