remote shell 



rsh [username@]hostname [-DNn] [-l username] command

rsh [-DNn] [-l username] [username@]hostname command


rsh executes command on the specified hostname. To do so, it must connect to a rshd service (or daemon) on the hostname machine.

When no user name is specified either with the -l option or as part of username@hostname, rsh connects as the user you are currently logged in as. If this is a domain user (that is, of the form domain\username), the whole name is sent. If you are not logged in as a domain user, the name machine_name\username) is sent.

For example, if you logged in as the domain user mydomain\myname, the command

rsh otherhost pwd

runs the pwd command as user mydomain\myname on the remote machine otherhost, as do the commands:

rsh otherhost -l mydomain/myname pwd
rsh otherhost -l mydomain\\myname pwd
rsh mydomain/myname@otherhost pwd
rsh mydomain\\myname@otherhost pwd

If an attempted rsh connection to the host fails because of an error matching "permission.*denied" or "remuser too long in a case-insensitive manner, the utility immediately tries again, sending only the user name without domain (or machine) information.


Because the rsh and rcp utilities resend the current without the domain if it is too long and the rlogin utility does not, a user may require two entries in the hosts.equiv or .rhosts file. If the full name (including domain) is too long for the rshd service (or daemon) being used, the user needs one entry with the full user name (including domain) for use with rlogind and a second with the the same user name minus the domain for use with rshd.

rsh actually sends two user names to the rshd service (or daemon), remuser and locuser.

remuser is your user name that you are currently logged into the client machine as (and includes domain information if you logged in as a domain user). It is called remuser by the service (or daemon) because from the point of view of the service (or daemon), the client machine is remote. remuser is the name that must appear in either the global hosts.equiv file or the appropriate .rhosts file on the server. remuser cannot be set by the user.

locuser is the user name that the service (or daemon) uses to execute the command on the server. Again, it is named as such, because from the point of view of the service (or daemon), the server is the local machine. This is either the user name that you are currently logged in as (minus any domain information if you are a domain user) or the user name explicitly entered on the rsh command line.

rsh copies its standard input to the remote command, the standard output of the remote command to its standard output, and the standard error of the remote command to its standard error (unless -N is specified).

Non-quoted shell metacharacters on the command line are interpreted on the local machine, while quoted metacharacters are interpreted on the remote machine. For example, the command

rsh otherhost cat remotefile >> localfile

appends the remote file remotefile to the local file localfile, while

rsh otherhost cat remotefile \>\> other_remotefile

appends remotefile to other_remotefile.

rsh normally terminates when the remote command does.

If rsh fails with a TIMEOUT error on Windows 8.1/2012R2/10/2016/2019/11/2022 when it should have succeeded, the user can tell rsh to retry with:


A TIMEOUT error is indicated by the following error message:

A connection attempt failed because the connected party did not properly
respond after a period of time, or established connection failed because
connected host has failed to respond.



enables socket debugging on the TCP sockets used for communication with the remote host. This option also displays the locuser and remuser being sent to rshd.


Because rsh -D is looking at the world from the client machine's point of view (as opposed to the host machine's point of view), the name displayed as local_user is actually the one sent as remuser and the name displayed as remote_user is actually locuser.

This option is useful for determining the exact case of your domain and user names, which must be correct in the .rhosts and hosts.equiv files. Also if the local_user name contains a backslash (\), you are attempting to connect as a domain user.

-l username 

specifies the remote user name to be used when executing the command. This can also be specified by including username@hostname on the command line.


does not generate a separate standard error stream. All output is sent to standard output. This is useful when you are running an interactive command. For example,

rsh -N localhost cmd
rsh -N localhost sh -i
redirects input from the special device /dev/nul.


If you are having trouble connecting to rshd on a remote host, here are some possible solutions to your problems.

If you are receiving a "permission denied" error, it could be for one of the following reasons:

If you are receiving a "could not retrieve password" error when attempting to connect to a remote host running the MKS Toolkit rshd service, it most likely means that the rsetup command has not been used to create an entry in the LSA database for locuser.

If you are receiving connection to server failed error, it usually implies that either there is no rshd service (or daemon) running on the remote host or that there were more concurrent rsh requests than the remote host could handle.

Most versions of rshd have a limit to the length of user name they can handle. On some UNIX systems, this limit is as low as 14 characters. As a result, you may receive an error message stating that either remuser or locuser is too long.

When remuser is too long, you need a shorter user name on the client machine.

When the "locuser is too long" error is received, it means that not only is the locuser name longer than the server's limit, but, by extension, it is an invalid user name on that server.



When this environment varible is set, the rsh, rcp, rexec, and rlogin utilities retry up to five times if they get the WSAENOTSOCK error. The WSAENOTSOCK error is reported as:

An operation was attempted on something that is not a socket

When set, CTRL-D is used as the EOF (end-of-file) character when the input is from the console.


when set, rsh retries to establish a connection when it fails with a TIMEOUT error on Windows 8.1/2012R2/10/2016/2019/11/2022.


Possible exit status values are:


Successful completion.


An error occurred.


This product includes software developed by the University of California, Berkeley and its contributors.


All UNIX systems. Windows 8.1. Windows Server 2012 R2. Windows 10. Windows Server 2016. Windows Server 2019. Windows 11. Windows Server 2022.


When you are connected to rshd running on a Windows machine, it takes longer to run a command as a domain user than it does to run that same command as a local user. This extra time is the result of the server having to contact the network for the additional domain information.


PTC MKS Toolkit for System Administrators
PTC MKS Toolkit for Developers
PTC MKS Toolkit for Interoperability
PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


rcp, rexec, rlogin, rsetup, rshd

File Formats:
hosts.equiv, rhosts

MKS Toolkit Connectivity Solutions Guide

PTC MKS Toolkit 10.4 Documentation Build 39.