How to use the telnet command in Linux
Created
Telnet is an application protocol used on the Internet or local area network to provide a bidirectional interactive text-oriented communication facility using a virtual terminal connection. User data is interspersed in-band with Telnet control information in an 8-bit byte oriented data connection over the Transmission Control Protocol (TCP).
Installing Telnet Client on Linux
RHEL / CentOS / Fedora
dnf install telnet
Ubuntu / Debian
apt-get install telnet
Verify
telnet installmd.com 80
Trying ... Connected to installmd.com. Escape character is '^]'. Connection closed by foreign host.
Telnet client
telnet IP/HOST PORT
Help
telnet --help
info telnet
man telnet
GET /path/to/file.html HTTP/1.1 Host: installmd.com Connection: close
The syntax for the telnet command is as follows:
Usage:
telnet [-468EFKLacdfrx] [-X authtype] [-b hostalias] [-e escapechar] [-k realm] [-l user] [-n tracefile] [host [port]]
OPTIONS:
-4Force IPv4 address resolution.-6Force IPv6 address resolution.-7Strip 8th bit on input and output. Telnet is 8-bit clean by default but doesn't send the TELNET BINARY option unless forced.-8Specifies an 8-bit data path. This causes an attempt to negotiate the TELNET BINARY option on both input and output.-EStops any character from being recognized as an escape character.-FIf Kerberos V5 authentication is being used, the -F option allows the local credentials to be forwarded to the remote system, including any cre‐dentials that have already been forwarded into the local environment.-KSpecifies no automatic login to the remote system.-LSpecifies an 8-bit data path on output. This causes the BINARY option to be negotiated on output.-X atypeDisables the atype type of authentication.-aAttempt automatic login. Currently, this sends the user name via the USER variable of the ENVIRON option if supported by the remote system. The name used is that of the current user as returned by getlogin(2) if it agrees with the current user ID, otherwise it is the name associated with the user ID.-b hostaliasUses bind(2) on the local socket to bind it to an aliased address (see ifconfig(8) and the ''alias'' specifier) or to the address of another interface than the one naturally chosen by connect(2). This can be useful when connecting to services which use IP addresses for authentication and reconfiguration of the server is undesirable (or impossible).-cDisables the reading of the user's .telnetrc file. (See the toggle skiprc command on this man page.)-dSets the initial value of the debug toggle to TRUE.-e escapecharSets the initial telnet escape character to escapechar. If escapechar is omitted, then there will be no escape character.-fIf Kerberos V5 authentication is being used, the -f option allows the local credentials to be forwarded to the remote system.-k realmIf Kerberos authentication is being used, the -k option requests that telnet obtain tickets for the remote host in realm realm instead of the remote host's realm, as determined by krb_realmofhost.-l userWhen connecting to the remote system, if the remote system understands the ENVIRON option, then user will be sent to the remote system as the value for the variable USER. This option implies the -a option. This option may also be used with the open command.-n tracefileOpens tracefile for recording trace information. See the set tracefile command below.-rSpecifies a user interface similar to rlogin(1). In this mode, the escape character is set to the tilde (~) character, unless modified by the -e option.-xTurns on encryption of the data stream if possible.hostIndicates the official name, an alias, or the Internet address of a remote host.portIndicates a port number (address of an application). If a number is not specified, the default telnet port is used.