Telnet
Telnet
NAME
telnet — user interface to the TELNET protocol
SYNOPSIS
telnet [-468ELadr] [-S tos] [-b address] [-e escapechar] [-l user]
[-n tracefile] [host [port]]
DESCRIPTION
The telnet command is used for interactive communication with another
host using the TELNET protocol. It begins in command mode, where it
prints a telnet prompt ("telnet> "). If telnet is invoked with a host ar‐
gument, it performs an open command implicitly; see the description be‐
low.
Options:
-a Attempt automatic login. Currently, this sends the user name via
the USER variable of the NEW-ENVIRON option if supported by the
remote system. The username is retrieved via getlogin(3).
-b address
Use bind(2) on the local socket to bind it to a specific local
address.
-S tos Sets the IP type-of-service (TOS) option for the telnet connec‐
tion to the value tos.
-e escapechar
Sets the escape character to escapechar. If no character is sup‐
plied, no escape character will be used. Entering the escape
character while connected causes telnet to drop to command mode.
-l user
Specify user as the user to log in as on the remote system. This
is accomplished by sending the specified name as the USER envi‐
ronment variable, so it requires that the remote system support
the TELNET NEW-ENVIRON option. This option implies the -a option,
and may also be used with the open command.
-n tracefile
Opens tracefile for recording trace information. See the set
tracefile command below.
Protocol:
Once a connection has been opened, telnet will attempt to enable the
TELNET LINEMODE option. If this fails, then telnet will revert to one of
two input modes: either “character at a time” or “old line by line” de‐
pending on what the remote system supports.
In “old line by line” mode, all text is echoed locally, and (normally)
only completed lines are sent to the remote host. The “local echo char‐
acter” (initially “^E”) may be used to turn off and on the local echo
(this would mostly be used to enter passwords without the password being
echoed).
Commands:
The following telnet commands are available. Unique prefixes are under‐
stood as abbreviations.
Note that the current version of telnet does not support au‐
thentication.
close Close the connection to the remote host, if any, and return to
command mode.
start [input|output]
Attempt to begin encrypting. If you do not
specify input or output, encryption of both in‐
put and output is started.
stop [input|output]
Stop encrypting. If you do not specify input or
output, encryption of both is stopped.
Note that the current version of telnet does not support en‐
cryption.
environ arguments...
The environ command is used to propagate environment variables
across the telnet link using the TELNET NEW-ENVIRON protocol
option. All variables exported from the shell are defined,
but only the DISPLAY and PRINTER variables are marked to be
sent by default. The USER variable is marked to be sent if
the -a or -l command-line options were used.
undefine variable
Remove any existing definition of variable.
export variable
Mark the specified variable for propagation to the
remote host.
unexport variable
Do not mark the specified variable for propagation
to the remote host. The remote host may still ask
explicitly for variables that are not exported.
logout Send the TELNET LOGOUT protocol option to the remote host.
This command is similar to a close command. If the remote host
does not support the LOGOUT option, nothing happens. But if
it does, this command should cause it to close the connection.
If the remote side also supports the concept of suspending a
user's session for later reattachment, the logout command in‐
dicates that the session should be terminated immediately.
mode type Type is one of several options, depending on the state of the
session. Telnet asks the remote host to go into the requested
mode. If the remote host says it can, that mode takes effect.
character Disable the TELNET LINEMODE option, or, if the
remote side does not understand the LINEMODE op‐
tion, then enter “character at a time“ mode.
softtabs (-softtabs)
Attempt to enable (disable) the SOFT_TAB mode of
the LINEMODE option. This requires that the
LINEMODE option be enabled.
litecho (-litecho)
Attempt to enable (disable) the LIT_ECHO mode of
the LINEMODE option. This requires that the
LINEMODE option be enabled.
quit Close any open session and exit telnet. An end of file condi‐
tion on input, when in command mode, will trigger this opera‐
tion as well.
send arguments
Send one or more special telnet protocol character sequences
to the remote host. The following are the codes which may be
specified (more than one may be used in one command):
brk Sends the TELNET BRK (Break) sequence, which may have
significance to the remote system.
getstatus
If the remote side supports the TELNET STATUS command,
getstatus will send the subnegotiation to request that
the server send its current option status.
do cmd
dont cmd
will cmd
wont cmd
Sends the TELNET DO cmd sequence. cmd can be either a
decimal number between 0 and 255, or a symbolic name
for a specific TELNET command. cmd can also be either
help or ? to print out help information, including a
list of known symbolic names.
forw1
interrupt
If telnet is in localchars mode (see toggle localchars
below) and the interrupt character is typed, a TELNET
IP sequence (see send ip above) is sent to the remote
host. The initial value for the interrupt character
is taken to be the terminal's intr character.
reprint
If telnet is operating in LINEMODE or “old line by
line“ mode, then this character is taken to be the
terminal's reprint character. The initial value for
the reprint character is taken to be the terminal's
reprint character.
tracefile
This is the file to which the output, caused by
netdata or option tracing being TRUE, will be written.
If it is set to “-”, then tracing information will be
written to standard output (the default).
worderase
If telnet is operating in LINEMODE or “old line by
line“ mode, then this character is taken to be the
terminal's worderase character. The initial value for
the worderase character is taken to be the terminal's
worderase character.
slc state The slc command (Set Local Characters) is used to set or
change the state of the the special characters when the TELNET
LINEMODE option has been enabled. Special characters are
characters that get mapped to TELNET commands sequences (like
ip or quit) or line editing characters (like erase and kill).
By default, the local special characters are exported.
status Show the current status of telnet. This includes the name of
the remote host, if any, as well as the current mode.
verbose_encrypt
When the verbose_encrypt toggle is TRUE, TELNET
prints out a message each time encryption is en‐
abled or disabled. The initial value for this
toggle is FALSE. This flag only exists if en‐
cryption support is available.
z Suspend telnet. This command only works when the user is us‐
ing the csh(1).
! [command]
Execute a single command in a subshell on the local system.
If command is omitted, then an interactive subshell is in‐
voked.
? [command]
Get help. With no arguments, telnet prints a help summary.
If a command is specified, telnet will print the help informa‐
tion for just that command.
ENVIRONMENT
Telnet uses at least the HOME, SHELL, DISPLAY, and TERM environment vari‐
ables. Other environment variables may be propagated to the other side
via the TELNET NEW-ENVIRON option.
FILES
/etc/telnetrc global telnet startup values
~/.telnetrc user customized telnet startup values
HISTORY
The Telnet command appeared in 4.2BSD.
NOTES
On some remote systems, echo has to be turned off manually when in “old
line by line” mode.
BUGS
The source code is not comprehensible.