Glitch effect
Glitch effect

How Remote Shells Work

Remote shells operate through a client-server model. When you initiate a remote shell session, your local machine (the client) establishes a connection to a target system (the server) using any number of network protocols. Once connected, you can execute commands that run on the remote system, with the output sent back to your local terminal.

The process typically involves these steps:

  • Authentication: The remote system verifies your identity through credentials. In more novice style attacks, hackers may forego authentication all together to prioritize speed over security.

  • Session establishment: A secure communication channel is created.

  • Command execution: Your typed commands are transmitted to the remote system.

  • Result transmission: The remote system sends back command output and responses.

Common remote shell protocols

SSH (Secure Shell)

SSH is the most widely used and secure remote shell protocol. It encrypts all communication between client and server, making it the gold standard for remote access. SSH typically operates on port 22 and provides strong authentication mechanisms.

Telnet

An older protocol that transmits data in plain text, making it vulnerable to interception. While still used in some legacy systems, security professionals generally discourage Telnet usage due to its lack of encryption.

RSH (Remote Shell)

A basic remote shell protocol that predates SSH. Like Telnet, RSH lacks encryption and is considered insecure by modern standards. The National Institute of Standards and Technology (NIST) includes RSH in its cybersecurity glossary as a legacy protocol with significant security limitations.

RDP (Remote Desktop Protocol)

While primarily graphical, RDP provides full remote control over a Windows system, which includes access to command-line shells like Command Prompt and PowerShell. Gaining access via stolen credentials or vulnerabilities like BlueKeep can lead to complete system compromise.

HTTP/HTTPs (Hyper Text Transfer Protocol)

Web servers are a major target. Attackers can upload a "web shell," which is a script (e.g., in PHP, ASP.NET, or JSP) that executes server commands sent via a web browser. The shell's traffic is disguised as normal web traffic, making it difficult to detect, especially over HTTPS.

Covert tunneling protocols

DNS (Domain Name System)

Since DNS traffic is almost always allowed through firewalls, attackers use it for covert communication. They can encapsulate shell commands within DNS queries sent to a malicious DNS server they control. The responses from the server contain the command output. This is a slow but very stealthy method.

ICMP (Internet Control Message Protocol)

Best known for ping, ICMP is another protocol that is often permitted through network boundaries. Attackers can hide commands within the data portion of ICMP echo packets (pings). The target machine, infected with malware, can read these commands, execute them, and return the output in ICMP reply packets.

NTP (Network Time Protocol)

Although its primary purpose is to synchronize clocks, NTP packets can be manipulated to carry small amounts of data, potentially enabling a very slow and stealthy command-and-control channel.

Legitimate uses of remote shells

System administrators and IT professionals rely on remote shells for various essential tasks:

  • Server maintenance: Updating software, configuring services, and managing system resources.

  • Network troubleshooting: Diagnosing connectivity issues and monitoring network performance.

  • Database administration: Managing databases and executing maintenance scripts.

  • Cloud infrastructure management: Controlling virtual machines and containerized applications.

  • Automated deployments: Running scripts for software updates and system configurations.

Security risks and threat actors

While remote shells are valuable tools, they also present significant security risks when not properly secured:

Unauthorized access

Cybercriminals often target remote shell services to gain initial access to systems. Weak passwords, default credentials, and unpatched vulnerabilities can provide entry points for attackers.

Persistence and lateral movement

Once attackers establish remote shell access, they can:

  • Install backdoors for persistent access

  • Move laterally through networks to compromise additional systems

  • Execute malicious commands with elevated privileges

  • Steal sensitive data or install malware

Brute force attacks

SSH and other remote shell services are frequent targets of brute force attacks, where attackers systematically try different username and password combinations to gain access.

Best practices for securing remote shells

Authentication hardening

  • Implement strong, unique passwords for all accounts

  • Use public key authentication instead of password-based authentication

  • Enable multi-factor authentication when available

  • Regularly rotate credentials and remove unused accounts

Network security

  • Change default ports for remote shell services

  • Implement firewall rules to restrict access by IP address

  • Use VPN connections for additional security layers

  • Monitor network traffic for suspicious activity

System configuration

  • Keep remote shell software updated with latest security patches

  • Disable unnecessary remote shell services

  • Configure proper logging and monitoring

  • Implement intrusion detection systems

Access control

  • Follow the principle of least privilege

  • Regularly audit user permissions and access logs

  • Implement session timeouts for inactive connections

  • Use jump servers or bastion hosts for additional security

Remote shell vs. remote desktop

It's important to distinguish between remote shells and remote desktop connections:

Remote Shell: Provides text-based command-line access to a remote system. Users interact through typed commands and receive text-based responses. This method is lightweight and efficient for system administration tasks.

Remote Desktop: Provides full graphical user interface access to a remote system. Users can interact with windows, applications, and visual elements as if they were physically present at the remote machine.

Frequently Asked Questions

Glitch effectBlurry glitch effect

Strengthen your remote access security

Remote shells are powerful tools that enable efficient system administration and network management. However, their utility comes with significant security responsibilities. By implementing proper authentication, network security measures, and access controls, organizations can harness the benefits of remote shells while minimizing associated risks.

Understanding remote shell technology is essential for cybersecurity professionals, as these tools represent both legitimate administrative capabilities and potential attack vectors. Regular security assessments, monitoring, and adherence to best practices help ensure that remote shells serve their intended purpose without compromising organizational security.

Protect What Matters

Secure endpoints, email, and employees with the power of our 24/7 SOC. Try Huntress for free and deploy in minutes to start fighting threats.
Try Huntress for Free