Section 9.7. Distributed Processing


[Page 354 (continued)]

9.7. Distributed Processing

The power of distributed systems becomes clearer when you start moving around the network and logging into different hosts. Some hosts supply limited passwordless accounts with usernames like "guest" so those explorers can roam the network without causing any harm, although this practice is fading away as more people abuse the privilege. These days you almost always have to have an account on a remote computer in order to login. Three utilities for distributed access are:

  • rlogin and slogin, which allow you to log in to a remote Linux or UNIX host

  • rsh and ssh, which allow you to execute a command on a remote Linux or UNIX host

  • telnet, which allows you to execute commands on any remote host that has a telnet server

Of these, telnet is the most flexible, as other systems in addition to Linux support telnet servers. These three utilities are described in the following sections.


[Page 355]

9.7.1. Remote Logins: rlogin and slogin

To log into a remote host, use rlogin (Figure 9-18).

Figure 9-18. Description of the rlogin and slogin commands.

Utility: rlogin -ec [ -l userId ] hostName

slogin -ec [ -l userId ] hostName

slogin userID@hostName

rlogin and slogin attempt to log you into the remote host hostName. If you don't supply a username by using the -l option, your local username is used during the login process.

slogin creates a secure connection to the remote host by encrypting all packets used in the network connection.

If the remote host isn't set as an equivalent of your local host in your "$HOME/.rhosts" file, you are asked for your password on the remote host. slogin will honor that file as well as information found in $HOME/.shosts on the remote host.

Once connected, your local shell goes to sleep and the remote shell starts to execute. When you're finished with the remote login shell, terminate it in the normal fashion (usually with a Control-D) and your local shell will then awaken.

There are a few special "escape commands" that you may type that have a special meaning; each is preceded by the escape character, which is a tilde (~) by default. You may change this escape character by following the -e option with the preferred escape character. Here is a list of the escape commands:

SEQUENCE

MEANING

~.

Disconnect immediately from remote host.

~susp

Suspend remote login session. Restart remote login using fg.

~dsusp

Suspend input half of remote login session, but still echo output from login session to your local terminal. Restart remote login using fg.



In the following example, I logged into the remote host "vanguard" from my local host "csservr2", executed the date utility, and then disconnected:

$ rlogin vanguard                   ...remote login. Last login: Tue May 19 17:23:51 from csservr2.utdallas vanguard% date               ...execute a command on vanguard. Thu May 19 18:50:47 CDT 2005 
[Page 356]
vanguard% ^D ...terminate the remote login shell. Connection closed. $ _ ...back home again at csservr2!


9.7.2. Executing Remote Commands: rsh and ssh

If you want to execute just a single command on a remote host, rsh and ssh are much handier than rlogin and slogin (although they are actually the same program, respectively). Figure 9-19 shows how they work.

Figure 9-19. Description of the rsh and ssh commands.

Utility: rsh [-l userId ] hostName [ command ]

ssh [-l userId ] hostName [ command ]

ssh userID@hostName [ command ]

rsh and ssh attempt to create a remote shell on the host hostName to execute command. Both utilities copy standard input to command and copy the standard output and errors from command to their own standard output and error channels. Interrupt, quit, and terminate signals are forwarded to command, so you may Control-C a remote command. They terminate immediately after command terminates.

If you do not supply a username by using the -l option, your local username is used during the connection. If no command is specified, jsh and ssh start a remote shell.

Quoted metacharacters are processed by the remote host; all others are processed by the local shell.

A connection created by ssh is encrypted.


In the following example, I executed the hostname utility on my local "csservr2" host and the remote "vanguard" host:

$ hostname                   ...execute on my local host. csservr2 $ rsh vanguard hostname      ...execute on the remote host. vanguard $ _ 



[Page 357]

9.7.3. Remote Connections: telnet

telnet allows you to communicate with any remote host on the Internet that has a telnet server. Figure 9-20 describes how it works:

Figure 9-20. Description of the telnet command.

Utility: telnet [ host [ port ] ]

telnet establishes a two-way connection with a remote port. If you supply a hostname but not a port specifier, you are automatically connected to a telnet server on the specified host, which typically allows you to login to the remote machine. If you don't even supply a hostname, telnet goes directly into command mode (in the same fashion as ftp).

What happens after the connection is complete depends on the functionality of the port you're connected to. For example, port 13 of any Internet machine will send you the time of day and then disconnect, whereas port 7 will echo ("ping") back to you anything that you enter from the keyboard.

To enter command mode after you've established a connection, press the sequence Control-], which is the telnet escape sequence. This causes the command-mode prompt to be displayed, which accepts commands including the following:

COMMAND

MEANING

close

Close current connection.

open host [ port ]

Connect to host with optional port specifier.

quit

Exit telnet.

z

Suspend telnet.

?

Print summary of telnet commands.


Therefore, to terminate a telnet connection, press Control-] followed by the command quit.


In the following example, I used telnet to emulate the rlogin functionality by omitting an explicit port number with the open command:

$ telnet                      ...start telnet. telnet> ?                     ...get help. Commands may be abbreviated.  Commands are: 
[Page 358]
close close current connection logout forcibly logout remote user and close the connection display display operating parameters mode try to enter line-by-line or character-at-a-time mode open connect to a site quit exit telnet send transmit special characters ('send ?' for more) set set operating parameters ('set ?' for more) status print status information toggle toggle operating parameters ('toggle ?' for more) z suspend telnet ? print help information telnet> open vanguard ...get a login shell from vanguard. Trying 129.110.43.128 ... Connected to vanguard.utdallas.edu. Escape character is '^]'. SunOS 5.4 (vanguard) login: glass ...enter my username. Password: ...secret! Last login: Wed May 18 17:22:45 from csservr2.utdalla Thu May 19 17:23:21 CDT 2005 Erase is Backspace vanguard% date ...execute a command. Thu May 19 17:23:24 CDT 2005 vanguard% ^D ...disconnect from remote host. Connection closed by foreign host. $ _ ...telnet terminates.


You may specify the host name directly on the command line if you like:

$ telnet vanguard        ...specify host name on command line. Trying 129.110.43.128 ... Connected to vanguard.utdallas.edu. Escape character is '^]'. SunOS 5.4 (vanguard) login: glass                  ...enter username, etc... 


You may use telnet to try out some of the standard port services that I described earlier in this chapter. For example, port 13 prints the day and time on the remote host and then immediately disconnects:


[Page 359]

$ telnet vanguard 13      ...what's the remote time & day? Trying 129.110.43.128 ... Connected to vanguard.utdallas.edu. Escape character is '^]'. Thu May 19 17:26:32 2005 Connection closed by foreign host         ...telnet terminates. $ _ 


Similarly, port 79 allows you to enter the name of a remote user and obtain finger information:

$ telnet vanguard 79  ...manually perform a remote finger. Trying 129.110.43.128 ... Connected to vanguard.utdallas.edu. Escape character is '^]'. glass                               ...enter the username. Login name: glass             Name: Graham Glass Directory: /home/glass        Shell: /bin/csh No unread mail No Plan. Connection closed by foreign host.  ...telnet terminates. $ _ 


When system administrators are testing a network, they often use port 7 to check host connections. Port 7 echoes everything that you type back to your terminal, and is sometimes known as a "ping-port":

$ telnet vanguard 7                ...try a ping. Trying 129.110.43.128 ... Connected to vanguard.utdallas.edu. Escape character is '^]'. hi                                 ...my line. hi                                 ...the echo. there there ^]                             ...escape to command mode. telnet> quit                   ...terminate connection. Connection closed. $ _ 


telnet accepts numeric Internet addresses as well as symbolic names:

$ telnet 129.110.43.128 7       ... vanguard's numeric addr. Trying 129.110.43.128 ... Connected to 129.110.43.128. Escape character is '^]'. 
[Page 360]
hi ...my line. hi ...the echo. ^] ...escape to command mode. telnet> quit ...disconnect. Connection closed. $ _





Linux for Programmers and Users
Linux for Programmers and Users
ISBN: 0131857487
EAN: 2147483647
Year: 2007
Pages: 339

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net