telnet, tn, or tn3270 Command Purpose Connects the local host with a remote host, using the TELNET in- terface. Syntax { telnet | tn | tn3270 } [ -d ] [ -n TraceFile ] [ -e TerminalType ] [ Host [ Port ] ] Description The /usr/bin/telnet command, which may also be referred to as the tn or tn3270 command, operates in two different modes: command mode and input mode. Command Mode When the telnet command is issued without arguments, it enters command mode, as indicated by the telnet>, tn>, or the tn3270> prompt. A user can also enter command mode from input mode by pressing Ctrl-] for the telnet command, Ctrl-T for the tn com- mand, or Ctrl-C for the tn3270 command. In command mode, subcom- mands can be entered to manage the remote system. Some of these subcommands return you to the remote session upon completion. For those that do not, pressing the Enter key returns you to the remote session. Note: The default escape sequence for this command is Ctrl-] for the telnet command, Ctrl-T for the tn command, or Ctrl-C for the tn3270 command. This default can be overridden by changing the TNESC environment variable. To enter telnet command mode while connected to a remote host, type the TELNET escape key sequence. When in command mode, the standard operating system editing conventions, such as backspace, are available. Input Mode When the telnet command is issued with arguments, it performs an open subcommand with those arguments and then enters input mode. The type of input mode is either character-at-a-time or line-by- line, depending on what the remote system supports. In charac- ter-at-a-time mode, most text that is typed is immediately sent to the remote host for processing. In line-by-line mode, all text is echoed locally and completed lines are sent to the remote host. In either input mode, if the toggle localchars subcommand has a value of True, the user's QUIT, INTR, and FLUSH characters are trapped locally and sent as TELNET Protocol sequences to the re- mote host. The toggle autoflush and toggle autosynch subcom- mands cause this action to flush subsequent output to the termi- nal until the remote host acknowledges the TELNET sequence and to flush previous terminal input (in the case of QUIT and INTR char- acters). Terminal Type Negotiation The telnet command negotiates the terminal type, using the telnet protocol, and it sets the TERM environment variable according to what has been negotiated. To override the terminal negotiation from the console, use the EMULATE environment variable or the -e flag; or invoke the tn3270 command if you desire 3270 emulation. To determine whether ter- minal-type negotiation is performed, the following list describes the order of the telnet command processing: 1. The -e command-line flag. (No negotiation) 2. The EMULATE environment variable. (No negotiation) 3. The tn3270 command. (No negotiation) 4. If items 1, 2, and 3 are not present, terminal-type negotia- tion occurs automatically. If the client and the server negotiate to use a 3270 data stream, the keyboard mapping is determined by the following precedence: $HOME/.3270keys Specifies the user's 3270 keyboard mapping when the tn or telnet command is invoked. /etc/map3270 Specifies the user's 3270 keyboard mapping when the tn3270 command is invoked. /etc/3270keys.hft Specifies the standard workstation 3270 key- board (console) mapping. /etc/3270.keys Specifies the base 3270 keyboard mapping for use with limited function terminals. Secure Attention Key (SAK) Option In addition to terminal negotiation, the telnet command allows negotiation for the Secure Attention Key (SAK) option. This op- tion, when supported, provides the local user with a secure com- munication path to the remote host for tasks such as changing user IDs or passwords. If the remote host supports the SAK function, a trusted shell is opened on the remote host when the telnet send sak subcommand is issued. The SAK function can also be assigned to a single key available in telnet input mode, using the set sak subcommand. End-of-Line Convention The Telnet protocol defines the carriage-return line-feed (CR-LF) sequence 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 labeled "Return" or "Enter." When a Telnet server receives the Telnet end-of-line sequence, CR-LF, as input from a remote terminal, the effect is the same as if the user had pressed the end-of-line key on a local terminal. On ASCII servers, receiving the Telnet sequence CR-LF causes the same effect as a local user pressing the CR key on a local termi- nal. CR-LF and CR-NUL have the same effect on an ASCII server when received as input over a Telnet connection. Note: A Telnet user must be able to send CR-LF, CR-NULL, or LF. An ASCII user must be able to send CR-LF or CR-NULL. A Telnet user on an ASCII host should have a user-controllable mode to send either CR-LF or CR-NULL when the user presses the end-of-line key. The 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. This occurs, for example, when a Telnet server sends output or when the Telnet protocol incor- porates another application protocol. The telnet command "execs" (using the exec command) the /usr/sbin/login command to validate a user. This 1) allows all user and device attributes to take effect on telnet connections and 2) causes telnet connections to count against the maximum number of login sessions allowable at a time (determined by the maxlogins attribute). Attributes are defined in the /etc/security/user and /etc/security/login.cfg files. Restrictions * Earlier versions of the telnet command are not compatible with version 3.2 of the telnet command in sending escapes that emulate a high function terminal (HFT). Version 3.2 of the telnet com- mand sends only one escape when the escape key is hit, while pri- or versions send two escape characters. Therefore, when the telnet command is used to connect with a version 3.2 machine from a version 3.1 machine or earlier, the escape key produces two es- cape characters on the version 3.2 machine. This is fixed in a version 3.1 update. * The telnet command must allow transmission of 8-bit characters that are not in binary mode to implement ISO 8859 Latin code page. This is necessary for internationalization of the TCP/IP commands. * In order to support new character sets, the following was added to the hft-m, ibm5081, hft, hft-nam, hft-c, aixterm-m, and aixterm entries in the terminfo file: box1=\154\161\153\170\152\155\167\165\166\164\156, batt1=f1, box2=\154\161\153\170\152\155\167\165\166\164\156, batt2=f1md, font0=\E(B, font1=\E(0, The font0 and font1 entries are not understood by version 3.1 terminals. If you work on a version 3.1 machine, use either hft-m-old, hft-old, hft-nam-old, hft-c-old, aixterm-m-old, or aixterm-old terminfo entries. A common problem with the new terminfo file entries is that ver- sion 3.1 machines display a B character before each typed charac- ter when using the telnet command to connect to a VM system. If you see this, disconnect the telnet session and set the TERM en- vironment variable to its corresponding -old terminal type and reconnect. The B character comes from the font0=\E(B entry. The escape sequence is not understood by version 3.1 and there- fore the B is displayed on the screen. * The rlogind and telnetd daemons use POSIX line discipline to change the line discipline on the local tty. If POSIX line dis- cipline is not used on the local tty, echoing other line discip- lines may result in improper behavior. AIX TCP/IP must have PO- SIX line discipline to function properly. * The mouse cannot be used as an input device with the telnet command. * The telnet command does not support the APL data stream. Environment Variables The following environment variables can be used with the telnet command: EMULATE Overrides terminal-type negotiation in the same way as the -e flag. If the value of the EMULATE environment variable is defined as vt100 or 3270, the telnet command emulates a DEC VT100 terminal or 3270 terminal, respectively. If the EMULATE variable is not defined or has a value of none, the telnet com- mand operates normally. If the EMULATE variable is set to vt100 or 3270, the TERM environment variable in the remote login con- nection should be set to the same value. You can check this by using the env command after the connection is open. TNESC Specifies an alternate TELNET escape character, other than the default, Ctrl-] for the telnet command, Ctrl-T for the tn command, or Ctrl-C for the tn3270 command. To change the telnet escape sequence, set TNESC to the octal value of the character you want to use. Then export TNESC. For example, set TNESC to 35 to change the TELNET escape sequence to Ctrl-]. MAP3270 Specifies an alternate file that contains the user's 3270 keyboard mapping. The MAP3270 variable must contain the full path name to the alternate file. Create the alternate file using the same format as the default /etc/map3270 file. RM_HOST_LANG Specifies the EBCDIC code page being used on the re- mote 3270 host. Set the RM_HOST_LANG environment variable to the correct code page before you telnet (using the telnet command) to a non-English-speaking 3270 host. The default is English. Refer to the "List of Converters" in AIX Version 3.2 General Program- ming Concepts for possible code pages to use. Format the RM_HOST_LANG environment variable by specifying the /usr/lib/nls/loc/icon directory followed by the file name for the desired code page. The telnet command converts characters by using the iconv com- mand. Users can change the default conversion tables by using the genxlt command. Flags -d Turns debugging mode on. -e TerminalType Overrides terminal-type negotiation. Possible values are vt100, 3270, or none. -n TraceFile Records network trace information in the file speci- fied by the TraceFile variable. Subcommands Before entering each subcommand, press the escape key sequence. The escape sequence tells the program that non-text information follows. Otherwise, the program interprets subcommands as text. For each of the subcommands in the following list, you only need to type enough letters to uniquely identify the subcommand. (For example, q is sufficient for the quit subcommand.) This is also true for the arguments to the display, emulate, mode, set, and toggle subcommands. The telnet subcommands are: ? [Subcommand] Requests help on telnet subcommands. Without ar- guments, the ? subcommand prints a help summary. If a Subcommand variable is specified, help information is displayed for that subcommand. close Closes the TELNET connection and returns to telnet command mode when the open subcommand is used to establish the connec- tion. When the telnet command is invoked and a host is speci- fied, the close subcommand closes the TELNET connection and exits the telnet program (identical to the quit subcommand). display [Argument] Displays all of the set and toggle values if no Argument variable is specified; otherwise, lists only those values that match the Argument variable. emulate TerminalType Overrides terminal-type negotiation with the specified terminal type. Possible choices are: ? Prints help information. 3270 Emulates a 3270 terminal. none Specifies no emulation. vt100 Emulates a DEC VT100 terminal. All output received from the remote host is processed by the specified emulator. The initial terminal type to emulate can be specified through the EMULATE environment variable or the -e flag to the telnet command. Note: Only standard ASCII characters are allowed in emulation mode. mode Type Specifies the current input mode. When the Type vari- able has a value of line, the mode is line-by-line. When the Type variable has a value of character, the mode is character-at- a-time. Permission is requested from the remote host before entering the requested mode, and if the remote host supports it, the new mode is entered. open Host [Port] Opens a connection to the specified host. The Host specification can be either a host name or an Internet ad- dress in dotted-decimal form. If no Port variable is specified, the telnet subcommand attempts to contact a TELNET server at the default port. quit Closes a TELNET connection and exits the telnet program. A Ctrl-D in command mode also closes the connection and exits. send Arguments Sends one or more arguments (special character se- quences) to the remote host. Multiple arguments are separated by spaces. The following arguments can be used: ? Prints help information for the send subcommand. ao Sends the TELNET AO (Abort Output) sequence, which causes the remote host to flush all output from the remote system to the lo- cal terminal. ayt Sends the TELNET AYT (Are You There) sequence, to which the remote system can respond. brk Sends the TELNET BRK (Break) sequence, which causes the re- mote system to perform a kill operation. ec Sends the TELNET EC (Erase Character) sequence, which causes the remote host to erase the last character entered. el Sends the TELNET EL (Erase Line) sequence, which causes the remote system to erase the line currently being entered. escape Sends the current telnet escape character. The default escape sequence is Ctrl-] for the telnet command, Ctrl-T for the tn command, or Ctrl-C for the tn3270 command. ga Sends the TELNET GA (Go Ahead) sequence, which provides the remote system with a mechanism to signal the local system to re- turn control to the user. ip Sends the TELNET IP (Interrupt Process) sequence, which causes the remote system to cancel the currently running process. nop Sends the TELNET NOP (No Operation) sequence. sak Sends the TELNET SAK (Secure Attention Key) sequence, which causes the remote system to invoke the trusted shell. If the SAK is not supported, then an error message is displayed that reads: Remote side does not support SAK. synch Sends the TELNET SYNC sequence, which causes the remote system to discard all previously typed input that has not yet been read. This sequence is sent as TCP/IP urgent data. set VariableValue Sets the specified TELNET variable to the specified value. The special value off turns off the function associated with the variable entered. The display subcommand can be used to query the current setting of each variable. The variables that can be specified are: echo Toggles between local echo of entered characters and suppressing local echo. Local echo is used for normal process- ing, while suppressing the echo is convenient for entering text that should not be displayed on the screen, such as passwords. This variable can only be used in line-by-line mode. eof Defines the character for the telnet command. When the telnet command is in line-by-line mode, entering the eof charac- ter as the first character on a line sends the character to the remote host. The initial value for the eof character is the lo- cal terminal End-Of-File character. erase Defines the erase character for the telnet command. When the telnet command is in character-at-a-time mode and localchars has a value of true, typing the erase character sends the TELNET EC sequence to the remote host. The initial value for the erase character is the local terminal ERASE character. escape Specifies the telnet escape character, which puts the telnet command into command mode when connected to a remote host. This character can also be specified in octal in the TNESC en- vironment variable. flushoutput Defines the flush character for the telnet command. When localchars has a value of true, typing the flushoutput char- acter sends the TELNET AO sequence to the remote host. The ini- tial value for the flush character is Ctrl-O. If the remote host is running AIX, the flushoutput variable, unlike the other spe- cial characters defined by the set subcommand, only works in localchars mode since it has no termio equivalent. interrupt Defines the interrupt character for the telnet command. When localchars has a value of true, typing the interrupt charac- ter sends the TELNET IP sequence to the remote host. The initial value for the interrupt character is the local terminal interrupt (INTR) character. kill Defines the kill character for the telnet command. When the telnet command is in character-at-a-time mode and localchars has a value of true, typing the kill character sends the TELNET EL sequence to the remote host. The initial value for the kill character is the local terminal KILL character. quit Defines the quit character for the telnet command. When localchars has a value of true, typing the quit character sends the TELNET BRK sequence to the remote host. The initial value for the quit character is the local terminal QUIT character. sak Defines the Secure Attention Key (SAK) for the telnet com- mand. When the sak character is entered, the remote system is asked to create a trusted shell. If the remote host does not support the SAK, this sequence has no effect. status Shows the status of the telnet command, including the current mode and the currently connected remote host. toggle Arguments Toggles one or more arguments that control how the telnet command responds to events. Possible values are true and false. Multiple arguments are separated by spaces. The display subcommand can be used to query the current setting of each argument. The following arguments can be used: ? Displays valid arguments to toggle. autoflush If autoflush and localchars both have a value of true and the AO, INTR, and QUIT characters are recognized and transformed into TELNET sequences, the telnet command does not display any data on the user's terminal until the remote system acknowledges (with a TELNET timing mark option) that it has pro- cessed those TELNET sequences. The initial value of autoflush is true if the terminal has not done an stty noflsh, and false if it has. autosynch If autosynch and localchars are both true, then typing the INTR or QUIT character sends that character's TELNET se- quence, followed by the TELNET SYNC sequence. This procedure causes the remote host to discard all previously typed input un- til both of the TELNET sequences have been read and acted upon. The initial value of this toggle is false. crmod Toggles carriage return mode. When set to true, most car- riage return characters received from the remote host are mapped into a carriage return followed by a line feed. This mode does not affect the characters typed by the user, only those received from the remote host. This mode is useful when the remote host sends only a carriage return and not a line feed. The initial value of this toggle is false. debug Toggles debugging at the socket level. The initial value of this toggle is false. localchars Determines the handling of TELNET special characters. When this value is true, the ERASE, FLUSH, INTERRUPT, KILL, and QUIT characters are recognized locally and transformed into the appropriate TELNET control sequences (EC, AO, IP, BRK, and EL, respectively). When this value is false, these special charac- ters are sent to the remote host as literal characters. The ini- tial value of localchars is true in line-by-line mode and false in character-at-a-time mode. netdata Toggles the display of all network data (in hexadecimal format). The data is written to standard output unless a Trace- File value is specified with the -n flag on the telnet command line. The initial value of this toggle is false. options Toggles the display of internal TELNET Protocol process- ing options, such as terminal negotiation and local or remote echo of characters. The initial value of this toggle is false, indicating that the current options should not be displayed. lineterm Toggles the default end-of-line terminator to CR-LF (ASCII carriage-return line-feed). A telnet client running on an ASCII host should have the user configurable option to send ei- ther the CR-NUL or CR-LF terminator when the user presses the end-of-line key. The initial value of this toggle is false. z Suspends the TELNET process. To return to the TELNET process, use the fg built-in command of the csh or ksh command. Note: The z subcommand has the same effect as a Ctrl-Z key se- quence for any other process. It suspends Telnet execution and returns you to your original login shell. Examples In the following examples, if you enter the tn command instead of the telnet command, the command mode prompt is displayed as tn>. 1. To log in to the remote host host1 and perform terminal nego- tiation, enter: telnet host1 2. To log in to host1 as a vt100 terminal (no terminal type nego- tiation), choose one of the following methods: a. Use the following commands to set the EMULATE environment var- iable for this login session, then enter the telnet command: EMULATE=vt100; export EMULATE telnet host1 b. Use the -e flag to set the terminal type for this telnet ses- sion only: telnet -e vt100 host1 3. To log in to a remote host and then check the status of the telnet program, enter: telnet host3 Information similar to the following is displayed on your screen: Trying . . . Connected to host3 Escape character is '\^]'. AIX telnet (host3) IBM AIX Version 3 for RISC System/6000 login: Enter your login ID and password when you are prompted to do so. Press the Ctrl-T key sequence to receive the telnet> prompt. Enter the following at the telnet> prompt: status Information similar to the following is displayed on your screen: Connected to host3. Operating in character-at-a-time mode. Escape character is '\^]'. Upon completion of the status subcommand, press the Enter key to return to the remote prompt. Once you have completed your login, you can issue commands. To log out of the system and close the connection, press the Ctrl-D key sequence, or exit. 4. To log in to a remote host using the tn3270 command, enter: tn3270 hostname The host login screen should be displayed. You can now enter your login ID and password. Once you have completed your login, you can issue commands. To log out of the system and close the connection, press Ctrl-D or exit. Implementation Specifics This command is part of the TCP/IP Facility in Network Facilities in Base Operating System (BOS) Runtime. Files /etc/3270.keys Defines base 3270-keyboard mapping for use with limited function terminals. /etc/3270keys.hft Defines standard-workstation 3270-keyboard (console) mapping. Related Information Network Overview, Understanding the telnet Command in AIX Ver- sion 3.2 System User's Guide: Communications. The env command, login command, rexec command, rlogin com- mand, rsh command. The telnetd daemon. The map3270 file format, .3270keys file format. Connecting a Local Host to a Remote Host in AIX Version 3.2 Sys- tem User's Guide: Communications.