Next: , Previous: , Up: Top   [Contents][Index]

14 rsh: Remote shell

rsh executes commands on a remote host and copies its local standard input to that of the remote command, as well as the remote standard output to the local standard output, and the remote standard error to the local standard error. Locally raised interrupt, quit and terminate signals are all propagated to the remote command. Normally rsh terminates when the remote command does so.

When using the rsh command, you can for convenience create a link in your path, using a host name as name of the link. For example:

# ln -s /usr/bin/rsh hostname
# hostname ls

Afterwards, hostname will be passed to rsh as host name whenever the command hostname is issued.

rsh allows access to the remote host without the use of a password. The prerequisite is a suitable specification in ~/.rhosts. For details, See rcmd in The GNU C Library Reference Manual.

If no command is specified for rsh ar argument following the host name, then you will be logged in on the remote host using rlogin.

14.1 Command line options

The options are as follows :


Use only IPv4.


Use only IPv6.


Turns on socket debugging used for communication with the remote host.

-l user

By default, the remote username is the same as the local username. The -l option and the ‘username@host’ format allow the remote user name to be specified. Kerberos authentication is used, whenever available, and authorization is determined as in rlogin (see rlogin invocation).


Use /dev/null for all input, telling the server side that we send no material. This can prevent the remote process from blocking, should it optionally accept more input. The option is void together with encryption.

The next three options are available only if the program has been compiled with support for Kerberos authentication.

-k realm

The option requests rsh to obtain tickets for the remote host in realm realm instead of the remote host’s realm.


Turns off all Kerberos authentication.


Turns on encryption for all data passed via the rsh session. This may impact response time and CPU utilization, but provides increased security.

Finally, some compatibility options are present:

-e char

Ignored during normal operation, but passed on to rlogin when rsh is invoked without a command argument.

14.2 Note on stream redirections

Beware that non-quoted shell metacharacters are interpreted on the local machine, while quoted metacharacters are interpreted on the remote machine. For example:

rsh otherhost  cat remotefile >> localfile
rsh otherhost  cat remotefile ">>" otherfile

The first command appends the contents of remotefile, as found on the remote host, to the file localfile on the local host, since the local shell will intercept the redirection and will thus receive whatever the remote process directs to stdout.

In contrast, the second command will append the contents of the same file remotefile to a file named otherfile again, but this time the file is located on the remote host. The effect of quoting the redirection operator is to execute the command

cat remotefile >> localfile

entirely on the remote most, whence stdout at the remote host will have nothing to transmit to the listening local host!.

Next: , Previous: , Up: Top   [Contents][Index]