telnetQuick TCP port check (never for logins)
telnet opens a plain TCP connection to a host and port and lets you type into it. Its original job, remote login, is obsolete and insecure (everything is cleartext), but it remains a common way to check that a port accepts connections and to talk to text protocols such as HTTP and SMTP.
telnet HOST [PORT] (escape: Ctrl+] then 'quit')A developer says the app can't reach Postgres. Check the port from the app server with the tool the runbook mentions.
telnetA TCP client that connects your keyboard and screen to the socket. On Ubuntu 24.04 it's from GNU inetutils.
telnet resolves the host, then calls connect() for each address it gets, printing 'Trying ADDRESS...'. When the TCP handshake completes it prints 'Connected to' and the escape character, then copies your keystrokes to the socket line by line and prints whatever the server sends. On port 23 it would also negotiate telnet options (terminal type, echo) with a telnet server, but on other ports it behaves like a raw TCP client. Nothing is encrypted: a telnet login sends the password in clear text, which is why SSH replaced it everywhere. To leave a connection that the server keeps open, press Ctrl+] to reach the telnet> prompt and type quit. For scripting, nc is better: it has timeouts, exits cleanly and reports through its exit code.
HOST PORTConnect to PORT on HOST (default 23)Ctrl+]Escape to the telnet> command promptquit / closeAt the telnet> prompt: exit / close the connection-4 / -6Force IPv4 or IPv6-b ADDRBind to a local source addressRunning a telnet server (port 23) for remote administrationUsernames, passwords and all commands travel in clear text and can be captured by anyone on the path.
Use SSH; uninstall telnetd.Using telnet for port checks in scriptsIt waits about two minutes on filtered ports, needs interaction to exit, and its exit code doesn't reflect success well.
nc -z -w 3 host port # or timeout 3 bash -c '</dev/tcp/host/port'Getting stuck in a connection and pressing Ctrl+C repeatedlyCtrl+C is sent to the server; telnet's escape key is Ctrl+].
Ctrl+] then type quitTry these on a Linux machine of your own. Each task has a hint and a solution.
Use telnet to connect to port 22 on localhost and read the SSH banner, then leave the session.
Without telnet or nc, test whether TCP port 22 on localhost is open, giving up after 3 seconds.
telnetQuick TCP port check (never for logins)
telnet opens a plain TCP connection to a host and port and lets you type into it. Its original job, remote login, is obsolete and insecure (everything is cleartext), but it remains a common way to check that a port accepts connections and to talk to text protocols such as HTTP and SMTP.
telnet HOST [PORT] (escape: Ctrl+] then 'quit')A developer says the app can't reach Postgres. Check the port from the app server with the tool the runbook mentions.
telnetA TCP client that connects your keyboard and screen to the socket. On Ubuntu 24.04 it's from GNU inetutils.
telnet resolves the host, then calls connect() for each address it gets, printing 'Trying ADDRESS...'. When the TCP handshake completes it prints 'Connected to' and the escape character, then copies your keystrokes to the socket line by line and prints whatever the server sends. On port 23 it would also negotiate telnet options (terminal type, echo) with a telnet server, but on other ports it behaves like a raw TCP client. Nothing is encrypted: a telnet login sends the password in clear text, which is why SSH replaced it everywhere. To leave a connection that the server keeps open, press Ctrl+] to reach the telnet> prompt and type quit. For scripting, nc is better: it has timeouts, exits cleanly and reports through its exit code.
HOST PORTConnect to PORT on HOST (default 23)Ctrl+]Escape to the telnet> command promptquit / closeAt the telnet> prompt: exit / close the connection-4 / -6Force IPv4 or IPv6-b ADDRBind to a local source addressRunning a telnet server (port 23) for remote administrationUsernames, passwords and all commands travel in clear text and can be captured by anyone on the path.
Use SSH; uninstall telnetd.Using telnet for port checks in scriptsIt waits about two minutes on filtered ports, needs interaction to exit, and its exit code doesn't reflect success well.
nc -z -w 3 host port # or timeout 3 bash -c '</dev/tcp/host/port'Getting stuck in a connection and pressing Ctrl+C repeatedlyCtrl+C is sent to the server; telnet's escape key is Ctrl+].
Ctrl+] then type quitTry these on a Linux machine of your own. Each task has a hint and a solution.
Use telnet to connect to port 22 on localhost and read the SSH banner, then leave the session.
Without telnet or nc, test whether TCP port 22 on localhost is open, giving up after 3 seconds.