📄 telnet.txt
字号:
TELNET FUNCTIONALITY FOR C-KERMIT 7.0 AND KERMIT 95 1.1.19 Jeffrey Altman The Kermit Project Columbia UniversityMost recent update: Tue Jan 30, 2000CONTENTS 1. INTRODUCTION 2. SUPPORTED TELNET OPTIONS 3. TELNET OPTION MANAGEMENT 4. TELNET COMMAND SUMMARY 5. DIAGNOSING AND FIXING PROBLEMS CONNECTING TO TELNET SERVERS1. INTRODUCTIONThe Telnet protocol is one of the original protocols developed for the ARPAnet, the precursor to today's Internet. Telnet has evolved since the early 1970s due to the extensibility provided by its "option" model.To quote RFC854: "The purpose of the TELNET Protocol is to provide a fairly general, bi-directional, eight-bit byte oriented communications facility. Its primary goal is to allow a standard method of interfacing terminal devices and terminal-oriented processes to each other. It is envisioned that the protocol may also be used for terminal-terminal communication ("linking") and process-process communication (distributed computation)."Not so long ago the requirements for a Telnet client were fairly minimal:support echo management, window size notification, terminal type negotiation,and perhaps the transmission of environment variables from the client to theserver. Option negotiations were not time sensitive nor were theyinterdependent. Everyone was happy as long as each option specification wasfollowed and infinite negotiation loops were avoided.This simplicity began to change with the introduction of telnet options that provide for mutual authentication, data encryption, transport layer security, and synchronization of remote processes. The new options have orderand timing dependencies that require increased sophistication from both clientand server even though the original Telnet protocol specification did not change.Prior to C-Kermit 7.0 and K95 1.1.18, Kermit implemented Telnet protocol byopening a connection to the host and then transmitting the options that itsupported. What happened next was determined by how the connection was beingused. If the user told Kermit to: TELNET <host>then, immediately after the telnet options were transmitted, the terminalemulator started and began reading the incoming data. The rest of the Telnetprotocol implementation was purely reactive (with minor exceptions such aswindow-size changes): when a Telnet option was received it would be processedand a response sent if necessary.However, if the user said: SET HOST <host>then, after the telnet options were transmitted, Kermit would wait for thenext command from the user. If a CONNECT command was next the behavior wouldbe the same as for TELNET <host>. However, if Kermit was executing a scriptcontaining a series of INPUT and OUTPUT commands, the incoming telnet optionnegotiations would be processed while waiting for INPUT.This was adequate when there were no ordering or timing requirements for theTelnet negotiations. But with the introduction of authentication,encryption, transport-layer security, and the Kermit option for managing thestates of the Kermit server on both the workstation and host (see iksd.txt),it is necessary for Telnet negotiations to take place before the TELNETcommand enters the terminal emulator or the SET HOST command completes andallows any subsequent INPUT and OUTPUT commands to execute.The timing requirements for the telnet options supported by Kermit are asfollows: . START_TLS (Transport Layer Security) must be negotiated or refused before any other option. . AUTH (Authentication) must be negotiated or refused before ENCRYPT. AUTH must also be negotiated before the login process is initiated. . ENCRYPT (Encryption) must be negotiated/refused in both directions before it is safe to transmit any data that might be considered private, including Telnet options such as terminal type, location, xdisplay, or environment variables. ENCRYPT may not be negotiated if START_TLS has been negotiated or if AUTH has not been. . KERMIT (Internet Kermit Service) must wait for a response to any request for the peer to either turn on or off the Kermit Server capabilities in order to facilitate automatic uploading or downloading of files or processing of remote commands. . NEW_ENV (Transmission of Environment Variables to the Host) must be negotiated before the login process is initiated if the USER variable is to be requested from the client.The result is that Kermit must, to the best of its ability, attempt toprocess all of the above options before TELNET enters CONNECT mode or SETHOST completes to process the next command. Therefore it might take Kermitlonger to make a connection to a host than before.The reality is actually far different. Even if the CONNECT mode or firstINPUT command was executed sooner no user data could be received until theTelnet negotiations were complete. In addition, the timing of the initialINPUT command used to require that the length of time it takes to process theTelnet negotiations be factored in. This is no longer necessary and wasinappropriate in the first place. A login script should not have to bemodified for different connection types; the telnet negotiations should betransparent to the script. In C-Kermit 7.0 and Kermit 95 1.1.18 they are.2. SUPPORTED TELNET OPTIONSBINARY (Binary Transmission Mode) [RFC 856]When a telnet session is initiated, the connection is in Network VirtualTerminal (NVT) mode. NVT mode provides for special treatment of the carriagereturn (CR) control character to provide for deterministic parsing of theinput stream. Every CR that is transmitted must be followed by a line feed(LF) control character or a NUL control character. This enables an NVT todistiguish between the Carriage Return function and the End of Line indicator.This works fine for textual data. But in transmission of random binary datathere is the possibility that the sequence CR NUL might be misinterpreted.Binary mode removes the ambiguity by removing the requirement that CR be followed by either LF or NUL. It is negotiatied separatelyin each direction of data transmission. Binary transmission mode isnot required for transferring files with Kermit protocol but it might berequired when transfering files with Xmodem, Ymodem, or Zmodem.Binary mode is one of the most frequently misimplemented telnet options.Many implementation will negotiate Binary mode in only one directionbut apply it in both. Kermit provides workarounds forthese problems with its SET TELNET BUG BINARY-ME-MEANS-U-TOO and SET TELNET BUG BINARY-U-MEANS-ME-TOO commands.Kermit also provides the SET TELNET BINARY-TRANSFER-MODE command toautomatically enter binary mode at the start of a file transferand return to NVT mode when the transfer is completed.ECHO (Echo Mode) [RFC 857] When a telnet session is initiated, data is not echoed by the receiver.This means that a telnet client must echo each character locally asit is being sent to the host. While this reduces network traffic it can cause problems with terminal emulation and echoing of sensitive data.The echo option allows the each side to specify that it intends to echo the data that it receives. Normally this would be used to negotiatethat the server should echo the data it receives from the client. While itis possible for the client to state that it will echo the data receivedfrom the server this makes no sense and if negotiatied could result inan infinite loop of a single character being echoed back and forth.As a piece of telnet trivia, the BSD 4.2 telnet client would echo incoming data sent by the server if the host requested it. Kermitwill always respond WONT ECHO to a DO ECHO request when it is the client.SUPPRESS GO AHEAD (Suppress Go Ahead commands) [RFC 858]When a telnet session is initiated, all data transmitted by the sender is tobe followed by a Go Ahead (GA) command sequence. This is to enable telnet tobe used over half-duplex (two-way alternate) connections, and it gives thetelnet partner permission to transmit. But to our knowledge, all telnetsessions used over the Internet are full duplex connections. The Suppress GoAhead (SGA) option is negotiated in both directions to suppress thetransmission of the GA commands and treat the connection as full duplex(two-way simultaneous).LOGOUT (Logout user from host) [RFC 727]Some operating systems such as VMS support the notion of a login sessionthat can continue across separate telnet connections. If a telnet connection is prematurely interrupted by a network failure, the usermay reconnect to a pre-existing session on their next login attempt.The Telnet Logout option is sent by the telnet client just before thetcp/ip socket is closed to indicate to the host that the connection isbeing intentionally terminated by the user and is not being closeddue to a network error.SEND LOCATION (Send Terminal Location) [RFC 779]The Send Location option provides the host with a method for requestingthe location of the telnet client. When a location string has beenspecified with the SET TELNET LOCATION command, Kermit transmitsthis string to the host upon request.TERMINAL TYPE (Negotiate Terminal Type) [RFC 1091]The Terminal Type option allows the client and server to agree to a common terminal type that they both support. C-Kermitreports the value of the local TERM environment variable. Since Kermit 95supports more than 30 terminal types, it continues to offer additionalterminal tyeps to the host until the host accepts one.NAWS (Negotiate About Window Size) [RFC 1073]The Negotiate About Windows Size (NAWS) lets the client report its currentWindow size to the host. Every time the client's window size changes, the newsize is reported to the host automatically. It is not possible for the hostto report a window size to the client.XDISPLOC (Report X Window Display location) [RFC 1096]The X Windows display option is used to report to the host the addressof the local X Windows Server. Kermit sends the contents of thelocal DISPLAY environment variable or the string specified by theSET TELNET ENVIRONMENT DISPLAY command. AUTHENTICATION (Authenticate end user to host) [Internet-Draft]The AUTHENTICATION option is used to determine which if any authenticationmethod such as Kerberos 4, Kerberos 5, Secure Remote Password, etc, shouldbe used to authenticate the user to the host.ENCRYPTION (Encrypt session) [Internet-Draft]The ENCRYPTION option is used in conjunction with the AUTHENTICATE optionto encrypt all the data transmitted during the session. The ENCRYPTIONoption must be negotiated separately in each direction.NEW ENVIRONMENT (Report Environment to host) [RFC 1572]The NEW ENVIRONMENT option is used by the client to reply to requests from the server for either all or specified environment variables suchas DISPLAY, USERNAME, ACCOUNT, JOB, PRINTER, and SYSTEMTYPE. When theNEW ENVIRONMENT option is used to transmit the username, many telnet servers skip their login or username prompt and go directly to the password prompt.START TLS (Transmit Telnet over TLS) [Internet-Draft]The START TLS option is used by the client and server to determine whether thetelnet session should be restarted after first establishing a TLSv1 session.TLS provides strong encryption and optionally authenticates the client and theserver using X.509 certificates. START_TLS can be used with the AUTHENTICATEoption. When negotiatied START_TLS replaces the ENCRYPTION option.KERMIT (Synchronize Kermit File Transfers) [Internet-Draft]The Kermit option (invented by the Kermit Project) is designed to allow a Kermit file-transfer client and a Kermit server to synchronizetheir operations. This allows a change in "mode" of the server toautomatically switch the client into the complementary mode, and viceversa.FORWARD X (Transmit X Windows data over Telnet) [Internet-Draft]The FORWARD X option (invented by the Kermit Project) allows thetelnet server to redirect all output from X Windows clients and transmit it across to telnet connection. The telnet client thenforwards the data to the local X Windows server. When the telnetconnection is encrypted, both the telnet data and X Windows session dataare protected.3. TELNET OPTION MANAGEMENTOne of the benefits of processing all the Telnet options during the SET HOSTand TELNET commands is that it is now possible to configure policy requirements for a valid connection. This capability is necessary when theconnection must be secure (authenticated and encrypted) or else fail. Policies are specified with the new command: SET TELOPT [ <switch> ] <option> <local-mode> SET TELOPT [ <switch> ] <option> <remote-mode> SET TELOPT [ <switch> ] <option> <local-mode> <remote-mode>Which of the SET TELOPT command forms is used is dependent on the telnet option. Some options, such as authentication, terminal type and window size, are negotiated in one direction and others, such as binary, encryption and kermit are negotiated separately in each direction. For each option, themode can be:ACCEPTED Kermit does not offer the option but if the peer requests it Kermit agrees to use it.REFUSED Kermit does not offer the option and if the peer requests it Kermit refuses to use it.REQUESTED Kermit requests the option but agrees not to use it if the peer refuses it.REQUIRED Kermit requests the option and terminates the connection if the peer refuses it.The optional <switch> can be:/CLIENT Specifies that the command is being used to set the configuration for when Kermit is the Telnet client. This is the default when Kermit is not acting as an Internet Kermit Service./SERVER Specifies that the command is being used to set the configuration for when Kermit is the Telnet server. Kermit is a telnet server when it is accepting incoming connections with SET HOST * or when it is acting as an Internet Kermit Service. This is the default when Kermit is acting as an Internet Kermit Service.The options that can be configured and their default settings, as viewed bySHOW TELOPT, are: Telnet Option Me (client) U (client) Me (server) U (server) BINARY ACCEPTED ACCEPTED ACCEPTED ACCEPTED WONT WONT ECHO REFUSED ACCEPTED REQUESTED REFUSED WONT WONT SUPPRESS-GO-AHEAD ACCEPTED ACCEPTED REQUESTED REQUESTED WONT WONT SEND-LOCATION REQUESTED REFUSED REFUSED REFUSED WONT WONT TERMINAL-TYPE REQUESTED REFUSED REFUSED REQUESTED WONT WONT NAWS REQUESTED REFUSED REFUSED REQUESTED WONT WONT XDISPLOC REFUSED REFUSED REFUSED REFUSED WONT WONT AUTHENTICATION REQUESTED REFUSED REFUSED REQUESTED WONT WONT ENCRYPTION REQUESTED REQUESTED REQUESTED REQUESTED WONT WONT NEW-ENVIRONMENT REQUESTED REFUSED REFUSED REQUESTED WONT WONT start-tls ACCEPTED REFUSED REFUSED REQUESTED
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -