SkillPilotAI

telnet

telnet opens a plain-text connection to any TCP port of a remote host; whatever you type goes straight to the server. Today it is used for TCP port tests and for talking to text protocols (SMTP, HTTP) by hand, never for logins, because everything including the password travels unencrypted.

47.1 What it does, where it runs

PlatformHow to get it
WindowsOptional feature: Telnet Client (off by default)
LinuxPackage telnet / inetutils-telnet
macOSRemoved in 10.13: brew install telnet

47.2 How a port test works

3 results of a telnet port test (client 192.168.67.10 -> server 192.168.67.20)
  1. 1.SYN to port 25 passes the firewall, server replies SYN-ACK

  2. 2.Mail service sends its banner '220 mail.lab ESMTP ready': open

  3. 3.SYN to port 81 (no service): server replies RST = Connection refused

  4. 4.SYN to port 8080 dropped by the firewall: no reply

  5. 5.telnet stays at 'Trying...' and after about 2 minutes: Operation timed out = filtered

What you seePort state
Connected + bannerOpen (SMTP, SSH...)
Connected, blank screenOpen (HTTPS: the server waits for the client)
Connection refusedClosed (RST)
Trying... then timed outFiltered (firewall DROP)
Terminal
# open: SMTP bannertelnet 192.168.67.20 25HELO clientQUIT# closed: no servicetelnet 192.168.67.20 81# filtered: firewall DROPtelnet 192.168.67.20 8080
Output
$ telnet 192.168.67.20 25Trying 192.168.67.20...Connected to 192.168.67.20.Escape character is '^]'.220 mail.lab ESMTP ready250 OK221 ByeConnection closed by foreign host.$ telnet 192.168.67.20 81Trying 192.168.67.20...telnet: Unable to connect to remote host: Connection refused$ telnet 192.168.67.20 8080Trying 192.168.67.20...telnet: Unable to connect to remote host: Operation timed out

The 8080 test waited 2 minutes 15 seconds before timing out.

47.3 HTTP by hand

Terminal
telnet 192.168.67.20 80GET / HTTP/1.0# then press Enter twice
Output
Connected to 192.168.67.20.Escape character is '^]'.HTTP/1.1 200 OKConnection: closeContent-type: text/htmlContent-Length: 22 <h1>n047 lab web</h1>Connection closed by foreign host.

With HTTP/1.0 the server closes the connection after the response, hence 'Connection closed by foreign host'.

47.4 Windows telnet

  • Not enabled by default: where.exe telnet finds nothing on the office PC.
  • For a quick port check without enabling features use PowerShell Test-NetConnection -Port (True/False).
  • Options: /a auto logon, /e escape char, /f log file, /l user, /t vt100|vt52|ansi|vtnt.
  • Ctrl+] opens 'Microsoft telnet>': o host [port] open, c close, d display, st status, q quit.
  • sen ayt (Are You There), sen ip (Interrupt Process), sen brk (Break), sen <text>.
  • set logfile f, set localecho, set crlf, set term ...; u <setting> turns it off (u crlf sends only CR).
PowerShell
where.exe telnetTest-NetConnection 8.8.8.8 -Port 53 -InformationLevel Quiet
Output
$ where.exe telnetINFO: Could not find files for the given pattern(s).$ Test-NetConnection 8.8.8.8 -Port 53 -InformationLevel QuietTrue

47.5 Linux telnet (GNU inetutils): options

OptionWhat it does
-4 / -6Only IPv4 / IPv6
-8 / -L8-bit data (both / output)
-e char / -ESet / disable the escape character
-a / -KAuto login on / off
-l aliceRemote user (ENVIRON USER)
-n trace.txtRecord a trace file
-rrlogin-like interface (~. disconnect, ~^Z suspend)
-c / -dSkip ~/.telnetrc / debug
-x / -X / -kKerberos encryption/auth (not in the lab's Alpine build)

47.6 Linux command mode (Ctrl+])

  • open host [port], close (stay at telnet>), logout, quit, status, display, z, ! (local shell).
  • send: ao, ayt, brk, ip, abort, susp, ec/el, eof, synch, getstatus, do/dont/will/wont (raw negotiation).
  • set / unset: escape, echo, interrupt, erase, eof, tracefile...; slc export|import|check for local vs remote special chars.
  • environ define/export/list: variables sent to the remote; mode character|line (LINEMODE), isig, edit, softtabs, litecho.
  • auth / encrypt exist only in Kerberos builds: lab gave '?Invalid command'.
Output
$ telnet 192.168.67.20Connected to 192.168.67.20.Escape character is '^]'.server login: telnet> Connected to 192.168.67.20.Operating with LINEMODE optionNo line editingSpecial characters are local valuesRemote character echoEscape character is '^]'.telnet> Connection closed.

47.7 toggle: seeing the negotiation

  • toggle options: shows every option negotiation (RCVD WILL ECHO = the server will echo).
  • toggle netdata: every byte in hex; 0d0a at the end of 'HELO lab' shows Enter was sent as CR LF.
  • Others: prettydump, termdata, binary, crlf, crmod, localchars, skiprc, autologin.
Output
telnet> Will show option processing.Connected to 192.168.67.20.SENT DO SUPPRESS GO AHEADSENT WILL TERMINAL TYPESENT WILL NAWSSENT WILL LINEMODERCVD DO ECHOSENT WONT ECHORCVD WILL ECHOSENT DO ECHORCVD WILL SUPPRESS GO AHEADserver login: telnet> Will print hexadecimal representation of network traffic.< 0x0  323230206d61696c2e6c61622045534d54502072656164790a220 mail.lab ESMTP ready> 0x0  48454c4f206c61620d0a< 0x0  323530204f4b0a250 OK

47.8 Plaintext: the password is readable

Why telnet logins are unsafe
  1. 1.Client 192.168.67.10 logs in to 192.168.67.20:23 as alice

  2. 2.Password 'lab123' leaves in a plain TCP packet

  3. 3.Switch forwards it to the server

  4. 4.A sniffer (tcpdump) on the same network copies the packet

  5. 5.Password is directly readable: use SSH (port 22) for logins

Output
server$ tcpdump -i eth0 -nn -A 'tcp port 23'18:11:26.880888 IP 192.168.67.10.37862 > 192.168.67.20.23: Flags [P.], seq 31:37, ack 30, win 63, options [nop,nop,TS val 1462174240 ecr 711764605], length 6W'. *l.}alice18:11:27.883693 IP 192.168.67.10.37862 > 192.168.67.20.23: Flags [P.], seq 37:44, ack 47, win 63, options [nop,nop,TS val 1462175243 ecr 711766565], length 7W'..*l.%lab123

47.9 Comparison: telnet vs SSH

PointtelnetSSH
Port2322
EncryptionNone, plaintextEncrypted
AuthenticationPassword in clearPassword or keys, protected
Use todayPort tests, text protocolsAll remote logins

47.10 Common mistakes

  • Thinking a blank screen after Connected means closed: the port is open, the protocol (HTTPS) just waits for the client.
  • Thinking telnet is only for port 23: it connects to any TCP port (25, 80, 443, 6379...).
  • Using telnet to test UDP (DNS, SNMP): it cannot; use nc -u or nmap -sU.
  • Leaving a telnet server enabled on routers or servers.

47.11 Interview tips

  • telnet vs SSH: port 23 plaintext (password readable) vs port 22 encrypted with key auth.
  • Banner or blank = open, refused = closed, timeout = filtered.
  • Ctrl+] gives the telnet> prompt; toggle options shows negotiation.
  • On Windows without telnet: Test-NetConnection host -Port N.