📝 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.
📝 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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 bytes, the other allocating a dynamic buffer sized to the received packet length. Which statement is most precise?
📖 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 bytes, so the dynamic approach ensures the full message is captured, whereas a fixed ‑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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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?
📖 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.