Skip to content

Telnet And Remote Terminal Access

Category: Transport and Application Layer Protocols
Type: Network Concepts
Generated on: 2025-07-10 08:58:24
For: Network Engineering, Administration & Technical Interviews


This cheat sheet provides a comprehensive overview of Telnet and remote terminal access, covering its core concepts, practical applications, troubleshooting, and security considerations. It’s designed for both students learning networking and professionals managing network devices.

What is Telnet? Telnet (Telecommunication Network) is a protocol used to establish a bidirectional interactive text-oriented communication over a network. It allows a user to log in to a remote host and execute commands as if directly connected to the machine.

Why is it important (or rather, was important)? Historically, Telnet was a crucial tool for remote administration of network devices and servers. It offered a simple way to access a command-line interface (CLI) on a remote system.

Why is it now considered obsolete and largely replaced? Telnet transmits data, including usernames and passwords, in plaintext. This makes it highly vulnerable to eavesdropping and man-in-the-middle attacks. SSH (Secure Shell) provides encrypted communication and is the preferred protocol for secure remote access.

  • Client-Server Model: Telnet operates on a client-server model. The Telnet client runs on the user’s machine and initiates a connection to the Telnet server running on the remote host.
  • Port 23: Telnet traditionally uses TCP port 23 for communication.
  • NVT (Network Virtual Terminal): Telnet uses NVT to standardize the communication between different systems with varying terminal capabilities. It defines a common character set (7-bit ASCII) and control codes.
  • Telnet Options: These are negotiation mechanisms that allow the client and server to agree on additional functionalities beyond basic text transmission, such as terminal type, window size, and echo control.
  • Out-of-Band Signaling: Telnet uses out-of-band signaling to handle control functions like interrupt process (IP), abort output (AO), and Are You There (AYT). These are special sequences that are interpreted by the Telnet server, not passed to the application.

Step-by-Step Explanation:

  1. Connection Establishment: The Telnet client initiates a TCP connection to the Telnet server on port 23.

    Client (Port x) ----------------SYN--------------------> Server (Port 23)
    Client (Port x) <---------------SYN-ACK------------------- Server (Port 23)
    Client (Port x) ----------------ACK--------------------> Server (Port 23)
    (TCP Connection Established)
  2. Option Negotiation (Optional): The client and server may exchange option negotiation messages to agree on supported features. These messages start with the IAC (Interpret as Command) byte (255).

    Client ------IAC WILL ECHO-------> Server
    Client <-----IAC DO ECHO--------- Server
    (Example: Client requests the server to echo characters)
  3. Authentication: The server prompts for a username and password. These are transmitted in plaintext.

    Server: Username:
    Client: user123
    Server: Password:
    Client: password123 (Sent in plaintext!)
  4. Command Execution: After successful authentication, the user can execute commands on the remote host. All commands and output are transmitted in plaintext.

    Client: ls -l
    Server: (Output of ls -l command)
  5. Connection Termination: The user can terminate the session by typing exit or logout. The connection is then closed.

    Client: exit
    Client ----FIN----> Server
    Client <---FIN-ACK--- Server
    Client ----ACK----> Server
    (TCP Connection Closed)

Telnet Message Format:

A Telnet message consists of a sequence of bytes. The most important byte is the IAC (Interpret as Command) byte, which has a value of 255 (0xFF in hexadecimal). IAC signals the start of a Telnet command or option negotiation.

Common Telnet Commands (Following IAC):

  • IAC WILL The client requests to enable <option>.
  • IAC WON’T The client refuses to enable <option>.
  • IAC DO The server requests to enable <option>.
  • IAC DON’T The server refuses to enable <option>.
  • IAC SB Subnegotiation - used to exchange more detailed information about an option. SB stands for “Subnegotiation Begin,” and SE stands for “Subnegotiation End.”
  • IAC IP: Interrupt Process. Sends a signal to interrupt the current process on the server.
  • IAC AO: Abort Output. Tells the server to stop sending output.
  • IAC AYT: Are You There. Used to check if the server is still responsive.
  • IAC EC: Erase Character.
  • IAC EL: Erase Line.
  • IAC GA: Go Ahead (used in half-duplex mode, which is rare these days).

Example Option Negotiation (Client requesting echo):

  • Client sends: 255 251 01 (IAC WILL ECHO)
  • Server responds: 255 253 01 (IAC DO ECHO)

Hexadecimal Representation:

  • IAC (Interpret as Command): 0xFF or 255
  • WILL: 0xFB or 251
  • WON’T: 0xFC or 252
  • DO: 0xFD or 253
  • DON’T: 0xFE or 254
  • SB (Subnegotiation Begin): 0xFA or 250
  • SE (Subnegotiation End): 0xF0 or 240
  • ECHO: 0x01 or 1
  • SUPPRESS GO AHEAD: 0x03 or 3
  • TERMINAL TYPE: 0x18 or 24
  • WINDOW SIZE: 0x1F or 31
  • TERMINAL SPEED: 0x20 or 32

Wireshark Capture Example (Option Negotiation):

Frame 1: 66 bytes on eth0, capture_length 66
Ethernet II, Src: 00:11:22:33:44:55, Dst: 66:77:88:99:aa:bb
Internet Protocol Version 4, Src: 192.168.1.10, Dst: 192.168.1.20
Transmission Control Protocol, Src Port: 50000, Dst Port: 23, Seq: 1, Ack: 1, Len: 52
Source port: 50000
Destination port: 23
Sequence number: 1
Acknowledgement number: 1
Header length: 20 bytes
Flags: 0x018 (PSH, ACK)
Window size value: 65535
Checksum: 0x1234 [unverified]
[Stream index: 0]
Telnet
IAC (255)
WILL (251)
TERMINAL TYPE (24)

This Wireshark capture shows the client (192.168.1.10) sending an IAC WILL TERMINAL TYPE command to the server (192.168.1.20).

Historical Use Cases (Now largely replaced by SSH):

  • Remote Administration of Routers and Switches: Accessing the CLI of network devices for configuration and troubleshooting.
  • Server Management: Logging in to servers to start/stop services, monitor system resources, and perform administrative tasks.
  • Bulletin Board Systems (BBS): Connecting to text-based online communities.

Modern Use Cases (Mostly for Legacy Systems or Quick Tests):

  • Testing Connectivity to a Port: Verifying that a service is listening on a specific port. For example, telnet example.com 80 to test HTTP connectivity. (Note: This doesn’t guarantee the service is fully functional, just that a connection can be established).
  • Interacting with Simple Text-Based Services: Connecting to services that use a simple text-based protocol, although this is increasingly rare.

Example: Testing HTTP Connectivity:

Terminal window
telnet example.com 80
Trying 93.184.216.34...
Connected to example.com.
Escape character is '^]'.
GET / HTTP/1.1
Host: example.com
HTTP/1.1 200 OK
Cache-Control: max-age=604800
Content-Type: text/html; charset=UTF-8
... (rest of the HTTP response)
Connection closed by foreign host.

This example shows a successful Telnet connection to port 80 of example.com. The user then sends a simple HTTP GET request. The server responds with the HTTP response headers and the HTML content.

  • Connection Refused: The Telnet server is not running on the remote host, or a firewall is blocking port 23.
    • Troubleshooting: Verify that the Telnet server is installed and running on the remote host. Check firewall rules on both the client and server. Use netstat -an | grep :23 (Linux) or netstat -an | findstr :23 (Windows) on the server to see if the Telnet server is listening on port 23.
  • Connection Timed Out: The client is unable to reach the server due to network connectivity issues.
    • Troubleshooting: Verify network connectivity between the client and server using ping or traceroute. Check for any firewalls or network devices that might be blocking traffic.
  • Incorrect Username or Password: The user enters an incorrect username or password.
    • Troubleshooting: Double-check the username and password. Ensure that the user account is enabled on the remote host.
  • Terminal Display Issues: Characters are not displayed correctly due to terminal incompatibility.
    • Troubleshooting: Try setting the terminal type using the TERM environment variable (e.g., export TERM=vt100 on Linux/macOS or set TERM=vt100 on Windows). Some Telnet clients also have options to configure the terminal type.
  • Security Vulnerabilities: Telnet transmits data in plaintext, making it vulnerable to eavesdropping.
    • Solution: Avoid using Telnet for sensitive data or remote administration. Use SSH instead. Disable Telnet if not needed. If Telnet is unavoidable, consider using a VPN to encrypt the traffic between the client and server.
  • Firewall Blocking: Modern firewalls often block Telnet by default.
    • Troubleshooting: Check your firewall configuration to ensure that port 23 is open (if you absolutely must use Telnet, which is highly discouraged).

Enabling/Disabling Telnet Server (Linux - Debian/Ubuntu):

  • Install Telnet Server: sudo apt-get install telnetd
  • Start Telnet Server: sudo systemctl start inetd (or sudo systemctl start xinetd if using xinetd)
  • Enable Telnet Server on Boot: sudo systemctl enable inetd (or sudo systemctl enable xinetd)
  • Disable Telnet Server: sudo systemctl stop inetd (or sudo systemctl stop xinetd) and sudo systemctl disable inetd (or sudo systemctl disable xinetd)
  • Uninstall Telnet Server: sudo apt-get remove telnetd

Enabling/Disabling Telnet Server (Windows):

  • Enable Telnet Client and Server (Windows 10/11): Go to Control Panel -> Programs -> Turn Windows features on or off. Check the boxes for “Telnet Client” and “Telnet Server.”
  • Start Telnet Service: Open Services (search for “services” in the Start Menu), locate “Telnet,” and set its startup type to “Automatic” and start the service.
  • Disable Telnet Service: Stop the Telnet service and set its startup type to “Disabled.”

Important Security Note: Enabling the Telnet server on Windows is highly discouraged due to security risks. Use SSH instead.

Firewall Configuration (iptables - Linux):

  • Allow Telnet traffic: sudo iptables -A INPUT -p tcp --dport 23 -j ACCEPT
  • Deny Telnet traffic: sudo iptables -A INPUT -p tcp --dport 23 -j DROP
  • Remember to save the iptables rules! (e.g., sudo netfilter-persistent save on Debian/Ubuntu)

Firewall Configuration (Windows Firewall):

  • Create an inbound rule to allow TCP traffic on port 23, if absolutely necessary. Again, this is strongly discouraged.

Q: What is Telnet, and what is it used for?

A: Telnet is a protocol used to establish a bidirectional, interactive, text-oriented communication over a network. It allows a user to log in to a remote host and execute commands. Historically, it was used for remote administration of network devices and servers.

Q: What port does Telnet use?

A: Telnet uses TCP port 23.

Q: What are the security concerns associated with Telnet?

A: Telnet transmits data, including usernames and passwords, in plaintext, making it highly vulnerable to eavesdropping and man-in-the-middle attacks. This is the primary reason it’s considered insecure and should be avoided.

Q: What is NVT in Telnet?

A: NVT (Network Virtual Terminal) is a standard used by Telnet to provide a common interface between different systems with varying terminal capabilities. It defines a common character set (7-bit ASCII) and control codes.

Q: What are Telnet options? Give some examples.

A: Telnet options are negotiation mechanisms that allow the client and server to agree on additional functionalities beyond basic text transmission. Examples include:

  • ECHO: Controls whether the server echoes characters typed by the client.
  • SUPPRESS GO AHEAD: Used in half-duplex mode to control who can transmit data.
  • TERMINAL TYPE: Allows the client to inform the server about its terminal type.
  • WINDOW SIZE: Allows the client to inform the server about its window size.

Q: What is the IAC byte in Telnet?

A: The IAC (Interpret as Command) byte is a special byte with a value of 255 (0xFF in hexadecimal) that signals the start of a Telnet command or option negotiation.

Q: What are some alternatives to Telnet for remote access?

A: The primary alternative to Telnet is SSH (Secure Shell), which provides encrypted communication and is much more secure. Other alternatives include VPNs combined with other remote access tools.

Q: How would you troubleshoot a Telnet connection that is failing?

A: Here’s a troubleshooting approach:

  1. Verify basic network connectivity: Use ping to check if the client can reach the server.
  2. Check if the Telnet server is running: Use netstat (or its equivalent on Windows) on the server to see if it’s listening on port 23.
  3. Check firewall rules: Ensure that firewalls on both the client and server are not blocking traffic on port 23.
  4. Verify DNS resolution: Make sure the client can resolve the server’s hostname to the correct IP address.
  5. Check username and password: Ensure that the user is entering the correct credentials.
  6. Terminal emulation: Try a different terminal emulation setting if characters are not displaying correctly.

Q: Why is Telnet not recommended for production environments?

A: Because it transmits data in plaintext, making it vulnerable to eavesdropping and man-in-the-middle attacks. SSH provides encrypted communication and is the preferred protocol for secure remote access. Using Telnet in a production environment is a significant security risk.

  • SSH (Secure Shell): The secure alternative to Telnet, providing encrypted communication.
  • TCP/IP: The foundation of network communication, including Telnet.
  • Network Security: Concepts related to protecting network data and systems from unauthorized access.
  • Firewalls: Network security devices that control network traffic based on configured rules.
  • Virtual Private Networks (VPNs): Used to create secure connections over public networks.
  • PuTTY: A popular SSH and Telnet client.
  • netcat (nc): A versatile networking utility that can be used for various tasks, including testing network connectivity and port scanning.

This cheatsheet provides a comprehensive overview of Telnet. Remember to prioritize security and use SSH whenever possible. While Telnet is largely obsolete for secure remote access, understanding its principles can be helpful for understanding network protocols and troubleshooting basic connectivity issues.