The chapter explains how to use commands which enable you to:
Log in to a remote host from your local terminal.
Execute a specified command at a remote host.
Log in to a remote host using the Telnet protocol.
If
rlogin
is not supported, use
telnet
as an alternative.
Note
Any remote login is subject to the security features on the remote host. If you have difficulty logging in to a remote host, see your system administrator.
Before using any of these commands you might need to know the correct
host name or whether a remote host is currently reachable.
Use the
finger
,
who
,
rwho
,
ruptime
, and
ping
commands, described in
Chapter 10
to find this information.
13.1 Using rlogin to Log in to a Remote Host
You can log in to a remote host with
rlogin
, using
the following command syntax:
rlogin
[-luser
]
host_name
The
-l
option enables you to specify a remote user
name other than your local user name.
The
host_name
variable specifies the remote host.
The following steps show how to log in to a remote host
boston
where the login name is the same as that on the local host:
Enter the following
rlogin
command followed
by the name of the remote host.
For example:
%
rlogin boston
Password:
Enter your password.
When the system prompt is displayed, you are logged in to the remote host and can enter any command.
Press Ctrl/D to close the connection and return to your local host.
If you have an account on a remote host where your login name is different
from that on the local host, you should use the
-l
option
to log in to the remote host, as shown in the following steps.
Enter the
rlogin -l
command followed by
the remote login name and the name of the remote host.
For example:
%
rlogin -l celtic boston
Password:
Enter the password corresponding to the login name,
celtic
.
When the system prompt is displayed, you are logged in to the remote host and can enter any command.
Press Ctrl/D to close the connection and return to your local host.
In the following situations,
rlogin
will not prompt
for a password:
If your local host is listed in the
/etc/hosts.equiv
file on the remote host
If the name of your host (and optionally, your user name)
is listed in the
.rhosts
file in your home directory on
the remote host
For more information on
rlogin
, see the
rlogin
(1)
reference page.
13.2 Using rsh to Run Commands on a Remote Host
The
rsh
command enables you to run a single command
on a remote UNIX based host without logging in there.
If you need to run several
commands successively, you must log in to the remote host using either
rlogin
or
telnet
.
The
rsh
command has the following syntax:
rsh
[-l user
]
host_name command
The
-l
option enables you to log in to a remote host
where your login name,
user
,
is different from that on the local host.
If you do not specify the
-l
option,
rsh
assumes that your login name is
the same on both the local and remote hosts.
The
host_name
variable specifies the name of the remote host.
The
command
variable specifies the command you want to
run.
Note
If you do not specify a command to run remotely,
rsh
prompts you for login information to the remote host.
To use
rsh
, one of the following must be true:
Your local host is listed in the
/etc/hosts.equiv
file on the remote host.
Your host is listed in the
.rhosts
file
in your home directory on the remote host.
In the following example,
rsh
appends a file located
on a remote host to a file on the local host.
The remote file,
remfile2
, on host
remhost2
is appended to a local file
called
locfile
:
%
rsh remhost2 cat remfile2 >> locfile
13.3 Using telnet to Log in to a Remote Host
You can log in to a remote host by using the
telnet
command, which implements the Telnet protocol.
Using
telnet
you can:
Log in to a remote host
Execute any operating system command on the remote host
Enter
telnet
subcommands (see
Table 13-1)
for managing the remote session
The
telnet
command has the following syntax:
telnet
[ host_name
[ port
]
]
The
host_name
variable specifies the remote host.
If you omit the host name, you can use
the
open
subcommand to create a connection after you activate
the Telnet utility.
Example 13-1
shows how to use the
telnet
command to log in to a remote host named
star
,
use the
telnet
subcommand
status
, and
close the connection.
If you do not specify a
port
,
the Telnet protocol attempts to contact a Telnet server at the default port.
Example 13-1: Using the telnet Command
%
telnet star
[1]Trying 16.69.224.1...
[2]Connected to star.milkyway.galaxy.com.
[3]Escape character is '^]'.
(star.milkyway.galaxy.com) (ttyra)
[4]
login:
username
[4] [5]Password:
[6] [7]
%
^]
[8]telnet>
status
[8] [9]Connected to star.milkyway.galaxy.com.
[10]Operating in single character mode
Catching signals locally
Remote character echo
Local flow control
Escape character is '^]'.
[11]
%
^D
[12]Connection closed by foreign host.
[13]%
telnet star
[1] [14]Trying 16.69.224.1...
Connected to star.milkyway.galaxy.com.
Escape character is '^]'.
(star.milkyway.galaxy.com) (ttyra)
login:
username
Password:
%
^]
[8]telnet>
q
[15]Connection closed.
[16]
The
telnet
command is entered specifying the
host_name
as
stor
.
The default port is used.
[Return to example]
The
telnet
utility identifies
the address it is trying to connect with.
[Return to example]
The
telnet
utility completes
the connection and identifies the host it is connected with.
[Return to example]
The remote host system identifies itself and prompts for the user's login. [Return to example]
The user name on the host system is entered. [Return to example]
The remote system prompts for the user's password. [Return to example]
The user's password on the host system is entered. For security reasons, the password display is suppressed. [Return to example]
The default escape
sequence Ctrl/] is pressed to access the
telnet
subcommand prompt,
telnet>
.
[Return to example]
The
status
subcommand
is entered at the prompt.
[Return to example]
Several lines of status information are displayed. The exact display depends on system configuration. [Return to example]
The Return key is pressed to display the remote host prompt. [Return to example]
Ctrl/D is entered to quit the Telnet session from the host prompt. [Return to example]
The connection is closed by the remote host. [Return to example]
The connection and login procedure is repeated. [Return to example]
The
q
subcommand is entered
to quit the Telnet session from the
telnet>
subcommand
prompt.
Pressing Ctrl/D could also have been used.
[Return to example]
The local
telnet
utility closes the connection.
[Return to example]
You can enter the
telnet
command without any arguments
to access the
telnet
subcommand mode, indicated by the
telnet>
prompt.
The
telnet
subcommands are described in
Table 13-1.
Before entering a subcommand, you must enter the escape sequence, Ctrl/].
This sequence notifies the
telnet
program that the following
information is not text; otherwise,
telnet
would interpret
subcommands as text.
For each subcommand, you only need to type enough letters to uniquely
identify the command.
For example,
q
is sufficient for
the
quit
command.
For a complete list of
telnet
subcommands, see the
telnet
(1)
reference page.
Table 13-1: The telnet Subcommands