Telnet works by opening a TCP connection to a remote host, usually on port 23, and then exchanging data in a simple, largely unencrypted text protocol that lets a user type commands on a remote machine as if sitting at its console. The client sends keystrokes to the server, the server sends back output, and a special negotiation phase agrees on terminal options before the session becomes interactive.
Background: What Telnet Is and Where It Came From
Telnet dates to the late 1960s and the early ARPANET. Its name comes from "teletype network," a reference to the teletype terminals that were common at the time. The protocol was standardized in the early 1980s as RFC 854, with a companion document, RFC 855, covering the option negotiations. For years it was the standard way to log in to a remote Unix or VMS system, check email, edit files, or run programs on a machine across the country.
Telnet is a terminal emulation protocol, not a file transfer protocol and not a remote-desktop protocol. It carries a stream of characters in both directions and includes a small set of control codes so the two ends can agree on things like terminal type, window size, and echo behavior. It has no built-in encryption, no built-in authentication beyond whatever the remote operating system asks for, and no compression.
How a Telnet Session Works, Step by Step
A telnet session is a TCP connection with a structured conversation layered on top. The client and server exchange three-byte commands (IAC followed by a command byte and an option byte) to negotiate features. In practice, a session looks like this:
- Name resolution and connection. The client resolves the hostname to an IP address and opens a TCP connection to the server, conventionally on port 23.
- Option negotiation. The two sides exchange WILL, WONT, DO, and DONT messages to enable or refuse options such as terminal type, echo, and line mode. This negotiation can continue throughout the session.
- Login. The server presents a login prompt. The user types a username and password, which travel over the connection as plain text unless something else protects the link.
- Interactive session. The client sends each keystroke (or each line, depending on mode) to the server. The server runs a shell or application and sends output back. The client displays that output, interpreting control characters such as carriage return and line feed.
- Termination. Either side closes the connection, often after the user types
exitorlogout.
Because the protocol is text-oriented, it is easy to debug: a person can watch the raw byte stream and see exactly what was sent. That transparency is one reason telnet clients are still used to test other text-based services.
The Telnet Protocol in More Detail
Telnet's control information is embedded in the same stream as the data. The reserved byte 255 (hex FF), called IAC for "Interpret As Command," marks the start of a command. If a user actually wants to send the byte 255 as data, it must be doubled, a process called escaping. The main commands are WILL and DO (agreeing to enable an option) and WONT and DONT (refusing or disabling one). Options have numbers; for example, option 1 is echo, option 3 is suppress go-ahead, and option 24 is terminal type.
The protocol supports two broad modes. In character-at-a-time mode, each keystroke is sent immediately, which suits interactive programs. In line mode, the client buffers a line and sends it when the user presses Enter, which reduces overhead on slow links. The negotiation determines which mode is used and who handles echoing.
Telnet also defines a way to send out-of-band signals, such as an interrupt, using the Synch sequence. This matters because a plain TCP stream has no concept of a break or an urgent keystroke; telnet adds that.
Common Uses and Why Telnet Persists
Despite its age, telnet remains useful in several narrow roles:
- Testing TCP services. A telnet client can connect to almost any text-based port, such as SMTP on port 25 or HTTP on port 80, and let a person type a request by hand. This is a quick way to check whether a service is reachable and how it responds.
- Legacy equipment. Some routers, switches, industrial controllers, and older servers still expose a telnet management interface.
- Local lab work. In isolated or trusted networks, telnet is simple and requires no certificate setup.
- Learning and debugging. The visible, unencrypted stream makes it a teaching tool for understanding application protocols.
On the public internet, however, telnet has largely been replaced by SSH for remote login. SSH provides encryption, host authentication, and integrity checking, none of which telnet offers.
Security: The Central Limitation
The defining weakness of telnet is that everything, including passwords, crosses the network in clear text. Anyone who can observe the traffic, whether on a shared local network, a compromised router, or an ISP path, can read the session. There is also no cryptographic verification that the server is the one the user intended to reach, so an attacker positioned in the path can impersonate it.
For these reasons, the common guidance is to avoid telnet over untrusted networks and to prefer SSH for remote administration. Where legacy devices only speak telnet, a common workaround is to tunnel the telnet connection inside SSH or a VPN, so the telnet traffic never travels exposed. Disabling telnet on devices that do not need it is another standard hardening step.
Telnet Compared with SSH and Other Tools
SSH and telnet both provide interactive terminal access, but they differ sharply in design:
- Encryption: SSH encrypts the entire session; telnet does not.
- Authentication: SSH supports public-key authentication and verifies the server's identity; telnet relies on the remote system's login and does not verify the host.
- Port: Telnet conventionally uses TCP port 23; SSH uses port 22.
- Complexity: Telnet is simpler to implement and inspect; SSH requires key or certificate handling.
- Integrity: SSH detects tampering; telnet cannot.
Telnet is also sometimes confused with remote desktop tools. Those transmit a graphical screen and input events, while telnet transmits a character stream for a text terminal. A telnet session cannot show a graphical desktop.
Frequently Asked Questions
Is telnet still used today?
Yes, but mostly for testing text-based TCP services, for accessing legacy equipment on trusted networks, and for learning. It is no longer a recommended way to log in to systems over the public internet.
What port does telnet use?
The default is TCP port 23. A telnet client can also be pointed at other ports to test services, for example port 25 for SMTP or port 80 for HTTP.
Is telnet secure?
No. Telnet sends data, including passwords, without encryption and does not verify the server's identity. On untrusted networks it should be avoided or wrapped inside an encrypted tunnel such as SSH or a VPN.
Can telnet transfer files?
Not by itself. Telnet carries a terminal session. File transfer historically used separate protocols such as FTP, and on modern systems it is usually done over SSH-based tools.
Why does telnet sometimes show strange characters?
Telnet negotiates terminal options, and mismatches in terminal type or line-ending conventions can produce garbled output. Adjusting the client's terminal type or mode often resolves it.
What replaced telnet?
SSH is the main replacement for remote login, because it adds encryption and host authentication. For simple service testing, specialized tools and command-line utilities are also common.