Skip to main content

3. Remote Login - TELNET Protocol

3. REMOTE LOGIN -- TELNET PROTOCOL​

3.1 INTRODUCTION

  Telnet is the standard Internet application protocol for remote
login. It provides the encoding rules to link a user's
keyboard/display on a client ("user") system with a command
interpreter on a remote server system. A subset of the Telnet
protocol is also incorporated within other application protocols,
e.g., FTP and SMTP.

Telnet uses a single TCP connection, and its normal data stream
("Network Virtual Terminal" or "NVT" mode) is 7-bit ASCII with
escape sequences to embed control functions. Telnet also allows
the negotiation of many optional modes and functions.

The primary Telnet specification is to be found in RFC-854
[TELNET:1], while the options are defined in many other RFCs; see
Section 7 for references.

3.2 PROTOCOL WALK-THROUGH

  3.2.1  Option Negotiation: RFC-854, pp. 2-3

     Every Telnet implementation MUST include option negotiation and
     subnegotiation machinery [TELNET:2].

     A host MUST carefully follow the rules of RFC-854 to avoid
     option-negotiation loops.  A host MUST refuse (i.e, reply
     WONT/DONT to a DO/WILL) an unsupported option.  Option
     negotiation SHOULD continue to function (even if all requests
     are refused) throughout the lifetime of a Telnet connection.

     If all option negotiations fail, a Telnet implementation MUST
     default to, and support, an NVT.

     DISCUSSION:
          Even though more sophisticated "terminals" and supporting
          option negotiations are becoming the norm, all
          implementations must be prepared to support an NVT for any
          user-server communication.

  3.2.2  Telnet Go-Ahead Function: RFC-854, p. 5, and RFC-858

     On a host that never sends the Telnet command Go Ahead (GA),
     the Telnet Server MUST attempt to negotiate the Suppress Go
     Ahead option (i.e., send "WILL Suppress Go Ahead").  A User or
     Server Telnet MUST always accept negotiation of the Suppress Go







     Ahead option.

     When it is driving a full-duplex terminal for which GA has no
     meaning, a User Telnet implementation MAY ignore GA commands.

     DISCUSSION:
          Half-duplex ("locked-keyboard") line-at-a-time terminals
          for which the Go-Ahead mechanism was designed have largely
          disappeared from the scene.  It turned out to be difficult
          to implement sending the Go-Ahead signal in many operating
          systems, even some systems that support native half-duplex
          terminals.  The difficulty is typically that the Telnet
          server code does not have access to information about
          whether the user process is blocked awaiting input from
          the Telnet connection, i.e., it cannot reliably determine
          when to send a GA command.  Therefore, most Telnet Server
          hosts do not send GA commands.

          The effect of the rules in this section is to allow either
          end of a Telnet connection to veto the use of GA commands.

          There is a class of half-duplex terminals that is still
          commercially important: "data entry terminals," which
          interact in a full-screen manner.  However, supporting
          data entry terminals using the Telnet protocol does not
          require the Go Ahead signal; see Section 3.3.2.

  3.2.3  Control Functions: RFC-854, pp. 7-8

     The list of Telnet commands has been extended to include EOR
     (End-of-Record), with code 239 [TELNET:9].

     Both User and Server Telnets MAY support the control functions
     EOR, EC, EL, and Break, and MUST support AO, AYT, DM, IP, NOP,
     SB, and SE.

     A host MUST be able to receive and ignore any Telnet control
     functions that it does not support.

     DISCUSSION:
          Note that a Server Telnet is required to support the
          Telnet IP (Interrupt Process) function, even if the server
          host has an equivalent in-stream function (e.g., Control-C
          in many systems).  The Telnet IP function may be stronger
          than an in-stream interrupt command, because of the out-
          of-band effect of TCP urgent data.

          The EOR control function may be used to delimit the







          stream.  An important application is data entry terminal
          support (see Section 3.3.2).  There was concern that since
          EOR had not been defined in RFC-854, a host that was not
          prepared to correctly ignore unknown Telnet commands might
          crash if it received an EOR.  To protect such hosts, the
          End-of-Record option [TELNET:9] was introduced; however, a
          properly implemented Telnet program will not require this
          protection.

  3.2.4  Telnet "Synch" Signal: RFC-854, pp. 8-10

     When it receives "urgent" TCP data, a User or Server Telnet
     MUST discard all data except Telnet commands until the DM (and
     end of urgent) is reached.

     When it sends Telnet IP (Interrupt Process), a User Telnet
     SHOULD follow it by the Telnet "Synch" sequence, i.e., send as
     TCP urgent data the sequence "IAC IP IAC DM".  The TCP urgent
     pointer points to the DM octet.

     When it receives a Telnet IP command, a Server Telnet MAY send
     a Telnet "Synch" sequence back to the user, to flush the output
     stream.  The choice ought to be consistent with the way the
     server operating system behaves when a local user interrupts a
     process.

     When it receives a Telnet AO command, a Server Telnet MUST send
     a Telnet "Synch" sequence back to the user, to flush the output
     stream.

     A User Telnet SHOULD have the capability of flushing output
     when it sends a Telnet IP; see also Section 3.4.5.

     DISCUSSION:
          There are three possible ways for a User Telnet to flush
          the stream of server output data:

          (1)  Send AO after IP.

               This will cause the server host to send a "flush-
               buffered-output" signal to its operating system.
               However, the AO may not take effect locally, i.e.,
               stop terminal output at the User Telnet end, until
               the Server Telnet has received and processed the AO
               and has sent back a "Synch".

          (2)  Send DO TIMING-MARK [TELNET:7] after IP, and discard
               all output locally until a WILL/WONT TIMING-MARK is







               received from the Server Telnet.

               Since the DO TIMING-MARK will be processed after the
               IP at the server, the reply to it should be in the
               right place in the output data stream.  However, the
               TIMING-MARK will not send a "flush buffered output"
               signal to the server operating system.  Whether or
               not this is needed is dependent upon the server
               system.

          (3)  Do both.

          The best method is not entirely clear, since it must
          accommodate a number of existing server hosts that do not
          follow the Telnet standards in various ways.  The safest
          approach is probably to provide a user-controllable option
          to select (1), (2), or (3).

  3.2.5  NVT Printer and Keyboard: RFC-854, p. 11

     In NVT mode, a Telnet SHOULD NOT send characters with the
     high-order bit 1, and MUST NOT send it as a parity bit.
     Implementations that pass the high-order bit to applications
     SHOULD negotiate binary mode (see Section 3.2.6).


     DISCUSSION:
          Implementors should be aware that a strict reading of
          RFC-854 allows a client or server expecting NVT ASCII to
          ignore characters with the high-order bit set.  In
          general, binary mode is expected to be used for
          transmission of an extended (beyond 7-bit) character set
          with Telnet.

          However, there exist applications that really need an 8-
          bit NVT mode, which is currently not defined, and these
          existing applications do set the high-order bit during
          part or all of the life of a Telnet connection.  Note that
          binary mode is not the same as 8-bit NVT mode, since
          binary mode turns off end-of-line processing.  For this
          reason, the requirements on the high-order bit are stated
          as SHOULD, not MUST.

          RFC-854 defines a minimal set of properties of a "network
          virtual terminal" or NVT; this is not meant to preclude
          additional features in a real terminal.  A Telnet
          connection is fully transparent to all 7-bit ASCII
          characters, including arbitrary ASCII control characters.







          For example, a terminal might support full-screen commands
          coded as ASCII escape sequences; a Telnet implementation
          would pass these sequences as uninterpreted data.  Thus,
          an NVT should not be conceived as a terminal type of a
          highly-restricted device.

  3.2.6  Telnet Command Structure: RFC-854, p. 13

     Since options may appear at any point in the data stream, a
     Telnet escape character (known as IAC, with the value 255) to
     be sent as data MUST be doubled.

  3.2.7  Telnet Binary Option: RFC-856

     When the Binary option has been successfully negotiated,
     arbitrary 8-bit characters are allowed.  However, the data
     stream MUST still be scanned for IAC characters, any embedded
     Telnet commands MUST be obeyed, and data bytes equal to IAC
     MUST be doubled.  Other character processing (e.g., replacing
     CR by CR NUL or by CR LF) MUST NOT be done.  In particular,
     there is no end-of-line convention (see Section 3.3.1) in
     binary mode.

     DISCUSSION:
          The Binary option is normally negotiated in both
          directions, to change the Telnet connection from NVT mode
          to "binary mode".

          The sequence IAC EOR can be used to delimit blocks of data
          within a binary-mode Telnet stream.

  3.2.8  Telnet Terminal-Type Option: RFC-1091

     The Terminal-Type option MUST use the terminal type names
     officially defined in the Assigned Numbers RFC [INTRO:5], when
     they are available for the particular terminal.  However, the
     receiver of a Terminal-Type option MUST accept any name.

     DISCUSSION:
          RFC-1091 [TELNET:10] updates an earlier version of the
          Terminal-Type option defined in RFC-930.  The earlier
          version allowed a server host capable of supporting
          multiple terminal types to learn the type of a particular
          client's terminal, assuming that each physical terminal
          had an intrinsic type.  However, today a "terminal" is
          often really a terminal emulator program running in a PC,
          perhaps capable of emulating a range of terminal types.
          Therefore, RFC-1091 extends the specification to allow a







          more general terminal-type negotiation between User and
          Server Telnets.

3.3 SPECIFIC ISSUES

  3.3.1  Telnet End-of-Line Convention

     The Telnet protocol defines the sequence CR LF to mean "end-
     of-line".  For terminal input, this corresponds to a command-
     completion or "end-of-line" key being pressed on a user
     terminal; on an ASCII terminal, this is the CR key, but it may
     also be labelled "Return" or "Enter".

     When a Server Telnet receives the Telnet end-of-line sequence
     CR LF as input from a remote terminal, the effect MUST be the
     same as if the user had pressed the "end-of-line" key on a
     local terminal.  On server hosts that use ASCII, in particular,
     receipt of the Telnet sequence CR LF must cause the same effect
     as a local user pressing the CR key on a local terminal.  Thus,
     CR LF and CR NUL MUST have the same effect on an ASCII server
     host when received as input over a Telnet connection.

     A User Telnet MUST be able to send any of the forms: CR LF, CR
     NUL, and LF.  A User Telnet on an ASCII host SHOULD have a
     user-controllable mode to send either CR LF or CR NUL when the
     user presses the "end-of-line" key, and CR LF SHOULD be the
     default.

     The Telnet end-of-line sequence CR LF MUST be used to send
     Telnet data that is not terminal-to-computer (e.g., for Server
     Telnet sending output, or the Telnet protocol incorporated
     another application protocol).

     DISCUSSION:
          To allow interoperability between arbitrary Telnet clients
          and servers, the Telnet protocol defined a standard
          representation for a line terminator.  Since the ASCII
          character set includes no explicit end-of-line character,
          systems have chosen various representations, e.g., CR, LF,
          and the sequence CR LF.  The Telnet protocol chose the CR
          LF sequence as the standard for network transmission.

          Unfortunately, the Telnet protocol specification in RFC-
          854 [TELNET:1] has turned out to be somewhat ambiguous on
          what character(s) should be sent from client to server for
          the "end-of-line" key.  The result has been a massive and
          continuing interoperability headache, made worse by
          various faulty implementations of both User and Server







          Telnets.

          Although the Telnet protocol is based on a perfectly
          symmetric model, in a remote login session the role of the
          user at a terminal differs from the role of the server
          host.  For example, RFC-854 defines the meaning of CR, LF,
          and CR LF as output from the server, but does not specify
          what the User Telnet should send when the user presses the
          "end-of-line" key on the terminal; this turns out to be
          the point at issue.

          When a user presses the "end-of-line" key, some User
          Telnet implementations send CR LF, while others send CR
          NUL (based on a different interpretation of the same
          sentence in RFC-854).  These will be equivalent for a
          correctly-implemented ASCII server host, as discussed
          above.  For other servers, a mode in the User Telnet is
          needed.

          The existence of User Telnets that send only CR NUL when
          CR is pressed creates a dilemma for non-ASCII hosts: they
          can either treat CR NUL as equivalent to CR LF in input,
          thus precluding the possibility of entering a "bare" CR,
          or else lose complete interworking.

          Suppose a user on host A uses Telnet to log into a server
          host B, and then execute B's User Telnet program to log
          into server host C.  It is desirable for the Server/User
          Telnet combination on B to be as transparent as possible,
          i.e., to appear as if A were connected directly to C.  In
          particular, correct implementation will make B transparent
          to Telnet end-of-line sequences, except that CR LF may be
          translated to CR NUL or vice versa.

     IMPLEMENTATION:
          To understand Telnet end-of-line issues, one must have at
          least a general model of the relationship of Telnet to the
          local operating system.  The Server Telnet process is
          typically coupled into the terminal driver software of the
          operating system as a pseudo-terminal.  A Telnet end-of-
          line sequence received by the Server Telnet must have the
          same effect as pressing the end-of-line key on a real
          locally-connected terminal.

          Operating systems that support interactive character-at-
          a-time applications (e.g., editors) typically have two
          internal modes for their terminal I/O: a formatted mode,
          in which local conventions for end-of-line and other







          formatting rules have been applied to the data stream, and
          a "raw" mode, in which the application has direct access
          to every character as it was entered.  A Server Telnet
          must be implemented in such a way that these modes have
          the same effect for remote as for local terminals.  For
          example, suppose a CR LF or CR NUL is received by the
          Server Telnet on an ASCII host.  In raw mode, a CR
          character is passed to the application; in formatted mode,
          the local system's end-of-line convention is used.

  3.3.2  Data Entry Terminals

     DISCUSSION:
          In addition to the line-oriented and character-oriented
          ASCII terminals for which Telnet was designed, there are
          several families of video display terminals that are
          sometimes known as "data entry terminals" or DETs.  The
          IBM 3270 family is a well-known example.

          Two Internet protocols have been designed to support
          generic DETs: SUPDUP [TELNET:16, TELNET:17], and the DET
          option [TELNET:18, TELNET:19].  The DET option drives a
          data entry terminal over a Telnet connection using (sub-)
          negotiation.  SUPDUP is a completely separate terminal
          protocol, which can be entered from Telnet by negotiation.
          Although both SUPDUP and the DET option have been used
          successfully in particular environments, neither has
          gained general acceptance or wide implementation.

          A different approach to DET interaction has been developed
          for supporting the IBM 3270 family through Telnet,
          although the same approach would be applicable to any DET.
          The idea is to enter a "native DET" mode, in which the
          native DET input/output stream is sent as binary data.
          The Telnet EOR command is used to delimit logical records
          (e.g., "screens") within this binary stream.

     IMPLEMENTATION:
          The rules for entering and leaving native DET mode are as
          follows:

          o    The Server uses the Terminal-Type option [TELNET:10]
               to learn that the client is a DET.

          o    It is conventional, but not required, that both ends
               negotiate the EOR option [TELNET:9].

          o    Both ends negotiate the Binary option [TELNET:3] to







               enter native DET mode.

          o    When either end negotiates out of binary mode, the
               other end does too, and the mode then reverts to
               normal NVT.


  3.3.3  Option Requirements

     Every Telnet implementation MUST support the Binary option
     [TELNET:3] and the Suppress Go Ahead option [TELNET:5], and
     SHOULD support the Echo [TELNET:4], Status [TELNET:6], End-of-
     Record [TELNET:9], and Extended Options List [TELNET:8]
     options.

     A User or Server Telnet SHOULD support the Window Size Option
     [TELNET:12] if the local operating system provides the
     corresponding capability.

     DISCUSSION:
          Note that the End-of-Record option only signifies that a
          Telnet can receive a Telnet EOR without crashing;
          therefore, every Telnet ought to be willing to accept
          negotiation of the End-of-Record option.  See also the
          discussion in Section 3.2.3.

  3.3.4  Option Initiation

     When the Telnet protocol is used in a client/server situation,
     the server SHOULD initiate negotiation of the terminal
     interaction mode it expects.

     DISCUSSION:
          The Telnet protocol was defined to be perfectly
          symmetrical, but its application is generally asymmetric.
          Remote login has been known to fail because NEITHER side
          initiated negotiation of the required non-default terminal
          modes.  It is generally the server that determines the
          preferred mode, so the server needs to initiate the
          negotiation; since the negotiation is symmetric, the user
          can also initiate it.

     A client (User Telnet) SHOULD provide a means for users to
     enable and disable the initiation of option negotiation.

     DISCUSSION:
          A user sometimes needs to connect to an application
          service (e.g., FTP or SMTP) that uses Telnet for its







          control stream but does not support Telnet options.  User
          Telnet may be used for this purpose if initiation of
          option negotiation is  disabled.

  3.3.5  Telnet Linemode Option

     DISCUSSION:
          An important new Telnet option, LINEMODE [TELNET:12], has
          been proposed.  The LINEMODE option provides a standard
          way for a User Telnet and a Server Telnet to agree that
          the client rather than the server will perform terminal
          character processing.  When the client has prepared a
          complete line of text, it will send it to the server in
          (usually) one TCP packet.  This option will greatly
          decrease the packet cost of Telnet sessions and will also
          give much better user response over congested or long-
          delay networks.

          The LINEMODE option allows dynamic switching between local
          and remote character processing.  For example, the Telnet
          connection will automatically negotiate into single-
          character mode while a full screen editor is running, and
          then return to linemode when the editor is finished.

          We expect that when this RFC is released, hosts should
          implement the client side of this option, and may
          implement the server side of this option.  To properly
          implement the server side, the server needs to be able to
          tell the local system not to do any input character
          processing, but to remember its current terminal state and
          notify the Server Telnet process whenever the state
          changes.  This will allow password echoing and full screen
          editors to be handled properly, for example.

3.4 TELNET/USER INTERFACE

  3.4.1  Character Set Transparency

     User Telnet implementations SHOULD be able to send or receive
     any 7-bit ASCII character.  Where possible, any special
     character interpretations by the user host's operating system
     SHOULD be bypassed so that these characters can conveniently be
     sent and received on the connection.

     Some character value MUST be reserved as "escape to command
     mode"; conventionally, doubling this character allows it to be
     entered as data.  The specific character used SHOULD be user
     selectable.







     On binary-mode connections, a User Telnet program MAY provide
     an escape mechanism for entering arbitrary 8-bit values, if the
     host operating system doesn't allow them to be entered directly
     from the keyboard.

     IMPLEMENTATION:
          The transparency issues are less pressing on servers, but
          implementors should take care in dealing with issues like:
          masking off parity bits (sent by an older, non-conforming
          client) before they reach programs that expect only NVT
          ASCII, and properly handling programs that request 8-bit
          data streams.

  3.4.2  Telnet Commands

     A User Telnet program MUST provide a user the capability of
     entering any of the Telnet control functions IP, AO, or AYT,
     and SHOULD provide the capability of entering EC, EL, and
     Break.

  3.4.3  TCP Connection Errors

     A User Telnet program SHOULD report to the user any TCP errors
     that are reported by the transport layer (see "TCP/Application
     Layer Interface" section in [INTRO:1]).

  3.4.4  Non-Default Telnet Contact Port

     A User Telnet program SHOULD allow the user to optionally
     specify a non-standard contact port number at the Server Telnet
     host.

  3.4.5  Flushing Output

     A User Telnet program SHOULD provide the user the ability to
     specify whether or not output should be flushed when an IP is
     sent; see Section 3.2.4.

     For any output flushing scheme that causes the User Telnet to
     flush output locally until a Telnet signal is received from the
     Server, there SHOULD be a way for the user to manually restore
     normal output, in case the Server fails to send the expected
     signal.

3.5. TELNET REQUIREMENTS SUMMARY

                                             |        | | | |S| |
| | | | |H| |F
| | | | |O|M|o
| | |S| |U|U|o
| | |H| |L|S|t
| |M|O| |D|T|n
| |U|U|M| | |o
| |S|L|A|N|N|t
| |T|D|Y|O|O|t
FEATURESECTIONTTe
                                             |        | | | | | |

Option Negotiation |3.2.1 |x| | | | | Avoid negotiation loops |3.2.1 |x| | | | | Refuse unsupported options |3.2.1 |x| | | | | Negotiation OK anytime on connection |3.2.1 | |x| | | | Default to NVT |3.2.1 |x| | | | | Send official name in Term-Type option |3.2.8 |x| | | | | Accept any name in Term-Type option |3.2.8 |x| | | | | Implement Binary, Suppress-GA options |3.3.3 |x| | | | | Echo, Status, EOL, Ext-Opt-List options |3.3.3 | |x| | | | Implement Window-Size option if appropriate |3.3.3 | |x| | | | Server initiate mode negotiations |3.3.4 | |x| | | | User can enable/disable init negotiations |3.3.4 | |x| | | | | | | | | | | Go-Aheads | | | | | | | Non-GA server negotiate SUPPRESS-GA option |3.2.2 |x| | | | | User or Server accept SUPPRESS-GA option |3.2.2 |x| | | | | User Telnet ignore GA's |3.2.2 | | |x| | | | | | | | | | Control Functions | | | | | | | Support SE NOP DM IP AO AYT SB |3.2.3 |x| | | | | Support EOR EC EL Break |3.2.3 | | |x| | | Ignore unsupported control functions |3.2.3 |x| | | | | User, Server discard urgent data up to DM |3.2.4 |x| | | | | User Telnet send "Synch" after IP, AO, AYT |3.2.4 | |x| | | | Server Telnet reply Synch to IP |3.2.4 | | |x| | | Server Telnet reply Synch to AO |3.2.4 |x| | | | | User Telnet can flush output when send IP |3.2.4 | |x| | | | | | | | | | | Encoding | | | | | | | Send high-order bit in NVT mode |3.2.5 | | | |x| | Send high-order bit as parity bit |3.2.5 | | | | |x| Negot. BINARY if pass high-ord. bit to applic |3.2.5 | |x| | | | Always double IAC data byte |3.2.6 |x| | | | |

Double IAC data byte in binary mode |3.2.7 |x| | | | | Obey Telnet cmds in binary mode |3.2.7 |x| | | | | End-of-line, CR NUL in binary mode |3.2.7 | | | | |x| | | | | | | | End-of-Line | | | | | | | EOL at Server same as local end-of-line |3.3.1 |x| | | | | ASCII Server accept CR LF or CR NUL for EOL |3.3.1 |x| | | | | User Telnet able to send CR LF, CR NUL, or LF |3.3.1 |x| | | | | ASCII user able to select CR LF/CR NUL |3.3.1 | |x| | | | User Telnet default mode is CR LF |3.3.1 | |x| | | | Non-interactive uses CR LF for EOL |3.3.1 |x| | | | | | | | | | | | User Telnet interface | | | | | | | Input & output all 7-bit characters |3.4.1 | |x| | | | Bypass local op sys interpretation |3.4.1 | |x| | | | Escape character |3.4.1 |x| | | | | User-settable escape character |3.4.1 | |x| | | | Escape to enter 8-bit values |3.4.1 | | |x| | | Can input IP, AO, AYT |3.4.2 |x| | | | | Can input EC, EL, Break |3.4.2 | |x| | | | Report TCP connection errors to user |3.4.3 | |x| | | | Optional non-default contact port |3.4.4 | |x| | | | Can spec: output flushed when IP sent |3.4.5 | |x| | | | Can manually restore output mode |3.4.5 | |x| | | | | | | | | | |