Loading...

Lab 62: SSH and Telnet - Remote Access

Validate remote access to a modern host using SSH with host key verification, then confirm legacy port reachability using a Telnet session. Exit each session cleanly to keep operator behavior predictable during troubleshooting.

network security troubleshooting

Scenario

You are working remotely and need to validate access to two services on the same host: secure administration via ssh and a legacy service reachable on TCP port 23. You must confirm network reachability, handle the initial SSH host key prompt correctly, exit cleanly from the remote shell, then perform a Telnet connection test to confirm that the legacy port is accepting connections.

Operator context

SSH is the standard for secure remote administration. Telnet is plaintext and should not be used for sensitive work, but it still appears in legacy environments where the practical use case is confirming basic TCP reachability.

Objective

  • Establish an SSH session to 192.168.0.42 as user admin and accept the host key prompt.
  • Exit the SSH session cleanly.
  • Connect to the same host over Telnet on port 23.
  • Terminate the Telnet session cleanly.

Concepts

  • SSH trust on first use: host keys, fingerprints, and ~/.ssh/known_hosts.
  • Remote session discipline: clean exits to avoid confusion while triaging multiple systems.
  • Telnet as plaintext TCP: useful for reachability testing but not for secure administration.
  • Port testing: “service reachable” versus “connection refused/timeouts” as a first pass signal.

Walkthrough

Step 1 : Connect to the remote host using SSH.
Command
ssh admin@192.168.0.42

On first connection, SSH prompts you to confirm the host key fingerprint. Accepting the prompt adds the host to your known_hosts file and protects you from silent man-in-the-middle changes later.

The authenticity of host '192.168.0.42' can't be established.
ECDSA key fingerprint is SHA256:examplekey.
Are you sure you want to continue connecting (yes/no/[fingerprint])?
yes

Warning: Permanently added '192.168.0.42' (ECDSA) to the list of known hosts.
admin@192.168.0.42's password:
Welcome to remote server.
Safety note

If you did not expect a host key prompt for this system, stop and validate the fingerprint out-of-band before proceeding.

Step 2 : Exit the SSH session cleanly.
Command
exit

Use a clean exit to keep your workflow predictable. This matters when you are jumping between multiple sessions and tracking which system you are actively operating on.

Connection closed.
Step 3 : Connect to the legacy service on TCP port 23.
Command
telnet 192.168.0.42 23

Telnet is plaintext and not suitable for secure administration. In modern workflows, the common use is to confirm that a TCP port is reachable and a service is listening.

Trying 192.168.0.42...
Connected to 192.168.0.42.
Escape character is '^]'.
Welcome to Legacy Server.
Step 4 : Close the Telnet session.
Command
quit

Terminate the Telnet session cleanly so the remote side closes the connection and you return to your local shell without ambiguity.

Connection closed by foreign host.

Common breakpoints

SSH prompts for a password but login fails

Verify the username, credentials, and that the SSH service is reachable. If authentication is key-based or MFA-backed, a password prompt may indicate you are not using the expected auth path.

Host key warning appears on reconnect

A changed host key can be legitimate (rebuild/rekey) or a security issue. Validate the fingerprint before removing entries from known_hosts.

Telnet returns “Connection refused”

The host is reachable, but nothing is listening on port 23 or a firewall is actively rejecting the connection. Treat this as a service or policy signal, not a routing signal.

Telnet hangs or times out

Timeouts usually indicate filtering or routing problems. If SSH works but Telnet times out, a firewall rule is the most likely explanation.

Cleanup checklist

If this is a lab host you will not reuse, remove the entry you added to known_hosts to avoid stale fingerprints during future exercises.

Commands
ssh-keygen -R 192.168.0.42
Success signal

Your known_hosts entry for 192.168.0.42 is removed and future connections behave as expected.

Reference

  • ssh <user>@<host> : Connects to a remote system using the SSH protocol.
    • ~/.ssh/known_hosts : Stores trusted host keys after first connection.
  • exit : Ends the current interactive shell session (used here to terminate SSH cleanly).
  • telnet <host> <port> : Opens a plaintext TCP session to a host/port for legacy access or reachability testing.
    • 23 : Default Telnet port.
  • quit : Closes the current Telnet session and returns to the local shell.
  • ssh-keygen -R <host> : Removes all keys belonging to a host from known_hosts.
    • -R : Deletes matching host entries.