Telnet Command Practice
While no longer used for secure administration, Telnet remains a quick and dirty way to test if a raw TCP port is open. This track drills both the initial CLI connection flags and the internal 'telnet>' prompt commands used to manage the session once connected.
Command Reference
cli
| Command | Description |
|---|---|
telnet example.com 80 | Connect to a specific port on a remote host (e.g., port 80 for HTTP). |
telnet -l alice example.com | Pass a specific username to the remote host upon connection. |
telnet -e '^C' example.com | Set a custom escape character (instead of the default ^]) to enter the telnet prompt. |
telnet -d example.com | Enable socket-level debugging mode for the connection. |
telnet -E example.com | Disable the escape character entirely, treating all characters as data (prevents dropping to the command prompt). |
interactive
| Command | Description |
|---|---|
open example.com 80 | From within the telnet> prompt, initiate a connection to a host on a specific port. |
close | From within the telnet> prompt, close the current connection but keep the telnet program running. |
quit | From within the telnet> prompt, completely exit the telnet program. |
status | From within the telnet> prompt, print the current status of the connection. |
display | From within the telnet> prompt, display current operating parameters (like the active escape character). |
send escape | From within the telnet> prompt, send the current escape character through to the remote system. |
Key Use Cases
- Test if a remote web server is accepting connections on port 80
- Connect to a legacy system and automatically pass a username using -l
- Change the default escape character (^]) using the -e flag
- Use the internal 'open' command to connect to a host from within the telnet prompt
- Gracefully close a stuck connection using the internal 'close' command
Frequently Asked Questions
Why is telnet considered insecure?
Telnet transmits all data, including usernames and passwords, in clear-text over the network. Anyone sniffing the network traffic can read the data. SSH (Secure Shell) should always be used for remote administration instead.
How do I exit a telnet session?
First, type the escape character (usually Ctrl+]). This drops you into the 'telnet>' prompt. From there, type 'quit' and press Enter to exit the program entirely.
Why use telnet instead of nc (netcat) for port testing?
You should generally prefer netcat (nc -zv) for automated port scanning. However, telnet is sometimes preferred for manual testing because it drops you into an interactive session where you can manually type HTTP requests or SMTP commands.
Ready to master Telnet commands?
Test your muscle memory with our spaced-repetition quiz system. Free forever.
