Skip to content
shellmap

telnetOpen a plaintext TCP session — legacy terminal + port-probe tool across all 5 shells

Equivalents in every shell

Bashunix
telnet example.com 25

Connects to a remote TCP port and starts a line-oriented session. SSH replaced `telnet` for shell access 25+ years ago — the only remaining legitimate uses are (1) port probing (`telnet host 25` shows the SMTP greeting), (2) BBS / MUD access, (3) embedded device serial-over-TCP. Any credentials traverse the wire in PLAINTEXT.

Zshunix
telnet example.com 25

Same external. macOS REMOVED `telnet` from the base install starting 10.13 (High Sierra) — install via `brew install telnet`, or use the shipped `nc` (BSD netcat) for port probing: `nc -vz example.com 25`.

Fishunix
telnet example.com 25

Same external. For port-probe use, fish makes piping cleaner: `echo '' | nc -w 2 example.com 25`. No fish-specific telnet completion or special handling.

PowerShellwindows
Test-NetConnection -ComputerName example.com -Port 25 -InformationLevel Detailed

PowerShell-native port probe (Windows 8 / Server 2012+). Returns a `[NetConnectionResult]` with `TcpTestSucceeded`, `RemoteAddress`, `PingSucceeded`. For raw socket I/O use `[System.Net.Sockets.TcpClient]::new('example.com',25)` and read its `NetworkStream` — closer to telnet semantics.

cmd.exewindows
telnet example.com 25

NOT installed by default since Windows Vista. Enable with `dism /Online /Enable-Feature /FeatureName:TelnetClient`. Microsoft recommends OpenSSH for any auth use and `Test-NetConnection` for probes — the bundled `curl.exe` (Win10 1803+) covers HTTP port probing without enabling the legacy capability.

Worked examples

Check whether an SMTP server is reachable on port 25

Bash
telnet smtp.example.com 25
PowerShell
Test-NetConnection -ComputerName smtp.example.com -Port 25
cmd.exe
telnet smtp.example.com 25

Quick port-open probe with a 2-second timeout and clear exit code

Bash
nc -vz -w 2 example.com 80
Fish
nc -vz -w 2 example.com 80
PowerShell
(Test-NetConnection -ComputerName example.com -Port 80 -WarningAction SilentlyContinue).TcpTestSucceeded

Manual SMTP HELO conversation for debugging

Bash
(printf 'HELO test\r\nQUIT\r\n'; sleep 1) | telnet smtp.example.com 25
PowerShell
$c = [System.Net.Sockets.TcpClient]::new('smtp.example.com',25); $r = [IO.StreamReader]::new($c.GetStream()); $r.ReadLine()

Gotchas

  • `telnet` is DEPRECATED for any use involving authentication — credentials traverse the network in cleartext. Anything that asks for a login (mail submission, router admin, FTP-over-telnet) should be migrated to SSH (`ssh user@host`) or a TLS-wrapped equivalent. Keep `telnet` only for non-credentialed probes.
  • Windows removed `telnet` from the default install starting Vista. `dism /Online /Enable-Feature /FeatureName:TelnetClient` enables it; the PowerShell-native `Test-NetConnection -Port` is the recommended modern probe and works on every Windows 8+ install without elevation or extra capabilities.
  • macOS removed `telnet` from the base system in 10.13 (High Sierra). The shipped replacement is `nc` (BSD netcat) — `nc -vz example.com 25` does a connect-and-close probe with verbose output and a portable exit code (`0` = open, `1` = closed/filtered).
  • Microsoft's `telnet.exe` ignores Ctrl-C. To exit, press Ctrl-] (close bracket) — this opens the in-program prompt; type `quit` and Enter. Many Unix `telnet` clients use the same escape but the shortcut is undiscoverable from the UI.
  • Some firewalls return TCP RST immediately on probe — `telnet` reports `Connection refused`. Others silently DROP — `telnet` hangs forever waiting for a response. Always set `nc -w 2` or `Test-NetConnection -InformationLevel Quiet` plus a timeout job; never rely on `telnet` itself to time out (it doesn't).

WSL & PowerShell Core notes

pwsh`Test-NetConnection` is the cross-platform-ish port probe — fully featured on Windows, partial on PowerShell Core 7+ on macOS/Linux (the `-Port` / `-CommonTCPPort` modes work; `-Traceroute` does not). For Unix pwsh the canonical pattern is `nc -vz host port` followed by an `$LASTEXITCODE` check.
WSLWSL ships `nc` and, with `apt install telnet`, the real telnet client. From PowerShell, `wsl nc -vz host port` gives you Unix-style probe semantics on Windows without enabling the legacy `telnet.exe` capability — useful in scripts that need to behave the same on both sides.

Common tasks using telnet

Related commands