rsh or remsh Command Purpose Executes the specified command at the remote host or logs into the remote host. Syntax { rsh | remsh } RemoteHost [ -n ] [ -l User ] [ Command ] Description The /usr/bin/rsh command executes the command specified by the Command parameter at the remote host specified by the RemoteHost parameter; if the Command parameter is not specified, the rsh command logs into the remote host specified by the RemoteHost parameter. The rsh command sends standard input from the local command line to the remote command and receives standard output and standard error from the remote command. Note: Since any input to the remote command must be specified on the local command line, you cannot use the rsh command to execute an interactive command on a remote host. If you need to execute an interactive command on a remote host, use either the rlogin command or the rsh command without specifying the Command parame- ter. If you do not specify the Command parameter, the rsh com- mand executes the rlogin command instead. Access Files If you do not specify the -l flag, the local user name is used at the remote host. If -l User is entered, the specified user name is used at the remote host. In either case, the remote host allows access only if at least one of the following conditions is satisfied: * The local user ID is not the root user, and the name of the lo- cal host is listed as an equivalent host in the remote /etc/hosts.equiv file. * If either the local user ID is the root user or the check of /etc/hosts.equiv is unsuccessful, the remote user's home directo- ry must contain a $HOME/.rhosts file that lists the local host and user name. For security reasons, any $HOME/.rhosts file must be owned by ei- ther the remote user or root, and only the owner should have read and write access. In addition to the preceding conditions, the rsh command also al- lows access to the remote host if the remote user account does not have a password defined. However, for security reasons, use of a password on all user accounts is recommended. Remote Command Execution While the remote command is executing, pressing the Interrupt, Terminate, or Quit key sequences sends the corresponding signal to the remote process. However, pressing the Stop key sequence stops only the local process. Normally, when the remote command terminates, the local rsh process terminates. To have shell metacharacters interpreted on the remote host, place the metacharacters inside " " (double quotes). Otherwise, the metacharacters are interpreted by the local shell. When using the rsh command, you can create a link to a path (to which you have permission to write), using a host name specified by the HostName parameter as the link name. For example: ln -s /usr/bin/rsh HostName Having established this link, you can specify the HostName param- eter and a command specified by the Command parameter from the command line, and the rsh command remotely executes the command on the remote host. The syntax is: HostNameCommand For example, if you are linked to remote host opus and want to perform the date command, enter: opus date Because you can not specify the -l User flag, the remote command is successful only if the local user has a user account on the remote host. Otherwise, the rsh command returns a Login incorrect error message. When you specify the HostName parameter without a command, the rsh command calls the rlogin command, which logs you in to the remote host. Again, for suc- cessful login, the local user must have a user account on the re- mote host. Flags -l User Specifies that the rsh command should log in to the re- mote host as the user specified by the User variable instead of the local user name. If this flag is not specified, the local and remote user names are the same. -n Redirects any input for the rsh command to the /dev/null dev- ice. Use this flag if you are in a shell that supports job con- trol and run the rsh command in the background. Examples In the following examples, the local host, host1, is listed in the /etc/hosts.equiv file at the remote host, host2. 1. To check the amount of free disk space on a remote host, enter: rsh host2 df The amount of free disk space on host2 is displayed on the local system. 2. To append a remote file to another file on the remote host, place the >> metacharacters in quotation marks, and enter: rsh host2 cat test1 ">>" test2 The file test1 is appended to test2 on remote host host2. 3. To append a remote file at the remote host to a local file, omit the quotation marks, and enter: rsh host2 cat test2 >> test3 The remote file test2 on host2 is appended to the local file test3. 4. To append a remote file to a local file and use a remote user's permissions at the remote host, enter: rsh host2 -l jane cat test4 >> test5 The remote file test4 is appended to the local file test5 at the remote host, with user jane's permissions. Implementation Specifics This command is part of the TCP/IP Facility in Network Facilities in Base Operating System (BOS) Runtime. Related Information Network Overview in AIX Version 3.2 System Management Guide: Communications and Networks. The rcp command, rexec command, rlogin command, telnet, tn, or tn3270 command. The rshd daemon. The hosts.equiv file format, .rhosts file format.