🎓 BookMCQ
← Back to 26. Standard Client Server Protocols

📝 SSH uses and applications (13 MCQs)

Remote Administration Through SSH

SSH supports secure administration of servers, routers and other networked systems by providing encrypted terminal access. Its services extend beyond interactive login to remote command execution, file exchange and forwarding of application connections. These uses share SSH's authenticated transport, so data is protected while crossing networks that cannot be assumed trustworthy. Its layered design combines identity checks with protection for subsequent application traffic.

Secure File Transfer and Port Forwarding

An SSH client can request an interactive shell, execute a single command, or access the SFTP subsystem for file operations. Local forwarding sends a client-side connection through the SSH server, while remote forwarding exposes a server-side listening port through the tunnel. These features carry application streams rather than changing the application protocol itself.

Authentication Methods and Application Channels

A user establishes SSH to a trusted server, verifies its host key and authenticates. The client then requests the desired service: a shell, command, SFTP subsystem or forwarding channel. The server checks permissions and opens the corresponding channel, and encrypted data flows through the existing SSH connection until the channel or session ends.

Running a Remote Command Without a Full Shell

An administrator can run ssh operator@host.example 'uptime' to request a remote command. The command executes on the server and its output returns through SSH. For file transfer, an SFTP client requests the SFTP subsystem and performs file operations without using the separate FTP command and data connection architecture.

SSH in System and Network Operations

SSH is common in data-center management, secure maintenance, automated deployments and remote support. Port forwarding can protect access to a service that lacks its own encryption, but it does not repair that service's application-level weaknesses. SFTP offers file transfer, while SCP is another SSH-based file-copy mechanism in common use. The same protected connection can support several independent application activities.

Limits and Misconceptions About SSH Uses

'SSH is only for command-line login' ignores file transfer and forwarding services. 'Port forwarding makes the forwarded application secure end to end' is too broad because SSH protects the tunnel, not necessarily traffic beyond its endpoints. 'SFTP is FTP protected with TLS' is wrong because SFTP is an SSH subsystem, not FTPS.

Selecting SSH Features for Network Scenarios

Given a scenario, choose an SSH shell for interactive administration, remote command execution for one-off tasks, SFTP for file operations and forwarding for tunneling a port. Explain where encryption applies and why server host-key verification matters. Distinguish SFTP from FTP and FTPS, and identify TCP port 22 in standard SSH examples.

SSH Service and Forwarding Terms

  • Remote command - Executes an instruction on another host.
  • SFTP - Transfers files through SSH.
  • Port forwarding - Tunnels application connections through SSH.
  • Shell channel - Carries interactive terminal input and output.
  • Host key - Authenticates the server to the client.
  • TCP port 22 - Receives standard SSH connections.
4
Easy
6
Medium
3
Hard

📝 All SSH uses and applications MCQs

Q1. If a UDP client mistakenly sets its remote socket address to its own IP address, what is the most likely outcome?

A.The client sends the packet to itself, receiving its own message. ✅
B.Server receives the message and echoes back correctly.
C.The packet is discarded by the network stack.
D.The server crashes due to an invalid address.
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: When the remote address points to the client itself, the datagram is sent back to the originating host. The client therefore receives the same packet it transmitted, creating a loopback effect. This behavior is typical for UDP because there is no connection state to prevent it.

Q2. Suppose a UDP server processes incoming packets sequentially without using select(). Two clients send packets at the same instant. Which inference about handling is correct?

A.The server will interleave bytes from both packets.
B.The server discards both packets because UDP cannot queue them.
C.The server will process the first packet entirely before reading the second one.
D.The server will randomly choose one packet to process. ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: Without multiplexing mechanisms, the server reads from the socket in the order the operating system delivers datagrams. The first packet that becomes available is fully consumed before the next recvfrom call returns, so the server processes one packet completely before handling the other.

Q3. A UDP echo server binds to port 0, letting the OS assign an ephemeral port. If a client later sends a packet to the advertised port number, what logical deduction is most accurate?

A.The server will always receive it because the OS updates the port number automatically.
B.The packet will be routed to the client itself.
C.The server may not receive it because the client may have cached an outdated port. ✅
D.The OS will reject the packet due to mismatched ports.
💡 Difficulty: hard | ✅ Correct: C

📖 Explanation: When the server initially binds to port 0, the OS chooses a temporary port that must be communicated to clients. If the client continues using an old port value, its datagram will be directed to the wrong endpoint, so the server may never see that packet.

Q4. Compare iterative and recursive UDP server designs in terms of resource usage. Which statement best reflects the difference?

A.Iterative servers reuse a single process, consuming less memory than recursive servers that spawn a new process per request. ✅
B.Recursive servers use less memory because they terminate after each request.
C.Both designs consume identical resources because UDP is connectionless.
D.Iterative servers require more CPU cycles due to context switching.
💡 Difficulty: easy | ✅ Correct: A

📖 Explanation: An iterative UDP server handles each request in the same process, avoiding the overhead of creating new processes or threads. Recursive designs fork a child for each request, which multiplies memory usage and incurs additional scheduling costs, making the iterative approach more resource‑efficient.

Q5. Evaluate the impact of including <arpa/inet.h> versus the misspelled <arpa/innet.h> in the UDP echo server source. Which effect is most accurate?

A.The program compiles but behaves incorrectly at runtime.
B.The program compiles but fails to resolve hostnames.
C.The program runs but cannot resolve host addresses.
D.Compilation fails due to undefined symbols, preventing the program from building. ✅
💡 Difficulty: medium | ✅ Correct: D

📖 Explanation: The header <arpa/inet.h> defines functions such as inet_addr and htons. Using a misspelled name provides no declarations, so the compiler cannot resolve those symbols, causing compilation errors and stopping the build process.

Q6. An analyst compares two UDP echo server implementations: one with a fixed buffer of 512512 bytes, the other allocating a dynamic buffer sized to the received packet length. Which statement is most precise?

A.The dynamic implementation can handle packets up to the maximum UDP payload, reducing the chance of truncation. ✅
B.The fixed‑size implementation always uses less memory than the dynamic one.
C.Both implementations have identical performance because memory allocation overhead is negligible.
D.The fixed‑size implementation is more secure because it prevents buffer‑overflow attacks.
💡 Difficulty: hard | ✅ Correct: A

📖 Explanation: A dynamic buffer sized to the actual datagram length eliminates the risk of silently discarding bytes when the payload exceeds the static limit. UDP packets can be up to 65 50765\,507 bytes, so the dynamic approach ensures the full message is captured, whereas a fixed 512512‑byte buffer may truncate larger messages.

Q7. Applying the principle of “least privilege”, which modification to the UDP echo server’s socket permissions best aligns with this concept?

A.Allow read, write, and execute for all users.
B.Open the socket on a privileged port (<1024) to limit access.
C.Disable all permission checks on the socket. ✅
D.Restrict the socket to bind only to the localhost interface.
💡 Difficulty: easy | ✅ Correct: C

📖 Explanation: Limiting the socket to the loopback interface ensures that only processes on the same host can communicate with the server, reducing exposure to external threats while still providing necessary functionality. This restriction embodies the least‑privilege principle by exposing the service only where it is needed.

Q8. Synthesize how catching SIGINT influences the graceful shutdown of a UDP echo server. Which description best captures this relationship?

A.By catching SIGINT, the server can close the socket, release bound ports, and write a shutdown log before exiting. ✅
B.Signal handling allows the server to immediately terminate without closing the socket, freeing resources automatically.
C.Signal handling is irrelevant for UDP because the protocol is stateless.
D.Catching SIGINT forces the server to ignore further client requests but keeps the socket open indefinitely.
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: When the process receives SIGINT and has a handler, it can perform cleanup tasks such as closing the socket descriptor, releasing the bound port, and optionally logging the shutdown event. This orderly termination prevents resource leaks and ensures that subsequent programs can bind to the same port without error.

Q9. You need to extend the UDP echo server to support message authentication using a shared secret key while preserving its iterative nature. Which architectural change best integrates this requirement?

A.Introduce a separate TCP connection for key exchange before each UDP packet.
B.Replace UDP with TCP to guarantee ordered delivery of authentication data.
C.Use IP‑level filtering to allow only packets from authenticated clients.
D.Embed a HMAC computed with the secret key into each packet and verify it upon receipt. ✅
💡 Difficulty: hard | ✅ Correct: D

📖 Explanation: Adding a HMAC to each datagram allows the server to authenticate the payload without altering the underlying UDP communication pattern. The server can verify the tag on receipt and echo only authenticated messages, preserving the simple iterative loop while providing integrity protection.

Q10. According to the provided code snippet, which header file is explicitly included to provide definitions for socket‑related functions?

A.<stdio.h>
B.<sys/socket.h> ✅
C.<string.h>
D.<unistd.h>
💡 Difficulty: easy | ✅ Correct: B

📖 Explanation: The header <sys/socket.h> declares the socket API, including socket(), bind(), sendto(), and recvfrom(). These functions are essential for creating and managing sockets, which is why the snippet includes this file alongside other system headers.

Q11. If a UDP client sends a datagram larger than the server’s receive buffer size, what logical consequence follows for the received data?

A.The excess bytes will be discarded, and the server receives only the first NN bytes where NN is the buffer size. ✅
B.The server will automatically expand its buffer to fit the datagram.
C.The server will reject the packet and send an ICMP error to the client.
D.The server will block until the client retransmits a smaller packet.
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: When a datagram exceeds the allocated buffer, the kernel truncates the payload to the buffer length and discards the remaining bytes. The application receives a shortened message without notification, which is a characteristic of UDP’s connectionless, best‑effort delivery model.

Q12. Compare the effect of using recvfrom() versus recv() in the UDP echo server. Which statement accurately reflects their functional difference?

A.recvfrom() provides the sender’s address, while recv() does not, making recvfrom() necessary for echoing. ✅
B.recv() automatically binds the socket, whereas recvfrom() requires manual binding.
C.Both functions are identical for UDP; the difference is only in syntax.
D.recv() can be used only with TCP sockets, making it invalid for UDP.
💡 Difficulty: medium | ✅ Correct: A

📖 Explanation: recvfrom() returns both the data and the source address, which is essential for an echo server that must send the response back to the original client. recv() lacks this address information, so it cannot be used to correctly route the echoed packet in a UDP context.

Q13. In the context of UDP echo servers, how does the concept of “idempotence” apply to repeated client requests caused by packet loss?

A.Idempotence ensures that each duplicate request produces a different response.
B.The server must store state to detect duplicates, violating idempotence.
C.Since the server simply echoes the payload, repeated requests yield the same response, satisfying idempotence. ✅
D.UDP guarantees delivery, so idempotence is irrelevant.
💡 Difficulty: medium | ✅ Correct: C

📖 Explanation: An echo server’s operation—returning exactly the received payload—means that sending the same request multiple times produces identical responses. This property matches the definition of idempotence, allowing the system to tolerate retransmissions caused by loss without adverse effects.

🔗 Related Topics (MCQs)