13    Working on a Remote Host

The chapter explains how to use commands which enable you to:

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:

  1. Enter the following rlogin command followed by the name of the remote host. For example:

    
    % rlogin boston
    Password:
    

  2. Enter your password.

    When the system prompt is displayed, you are logged in to the remote host and can enter any command.

  3. 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.

  1. 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:
    

  2. 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.

  3. Press Ctrl/D to close the connection and return to your local host.

In the following situations, rlogin will not prompt for a password:

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:

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:

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]

  1. The telnet command is entered specifying the host_name as stor. The default port is used. [Return to example]

  2. The telnet utility identifies the address it is trying to connect with. [Return to example]

  3. The telnet utility completes the connection and identifies the host it is connected with. [Return to example]

  4. The remote host system identifies itself and prompts for the user's login. [Return to example]

  5. The user name on the host system is entered. [Return to example]

  6. The remote system prompts for the user's password. [Return to example]

  7. The user's password on the host system is entered. For security reasons, the password display is suppressed. [Return to example]

  8. The default escape sequence Ctrl/] is pressed to access the telnet subcommand prompt, telnet>. [Return to example]

  9. The status subcommand is entered at the prompt. [Return to example]

  10. Several lines of status information are displayed. The exact display depends on system configuration. [Return to example]

  11. The Return key is pressed to display the remote host prompt. [Return to example]

  12. Ctrl/D is entered to quit the Telnet session from the host prompt. [Return to example]

  13. The connection is closed by the remote host. [Return to example]

  14. The connection and login procedure is repeated. [Return to example]

  15. 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]

  16. 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

Subcommand Description
? [subcommand] Displays help information. If a subcommand is specified, information about that subcommand is displayed.
close Closes the connection and returns to telnet command mode.
displa [argument] Displays all of the set and toggle values if no argument is specified; otherwise, lists only those values that match argument.
open host [port] Opens a connection to the specified host. The host specification can be either a host name or an Internet address in dotted decimal form. If no port is given, telnet attempts to contact a telnet server at the default port.
quit Closes a connection and exits the telnet program. Pressing a Ctrl/D in command mode also closes the connection and exits.
status Shows the status of telnet, including the current mode and the currently connected remote host.
z Opens a shell on the local host as specified by the SHELL environment variable. When you exit the shell by pressing Ctrl/D, telnet returns to the remote session.