5.10.5 Restrict Telnet and SSH Access: What It Actually Means and How to Get It Right
Picture this: you spend weeks hardening your servers, configuring firewalls, patching vulnerabilities — and then someone guesses a weak admin password on SSH from anywhere in the world. Game over. That's exactly the scenario control 5.10.5 is designed to prevent.
If you're working through security compliance frameworks like CIS Benchmarks, NIST 800-53, or internal audit requirements, you've probably seen "5.But what does it actually mean in practice? Day to day, 10. 5 restrict telnet and ssh access" listed as a requirement. And more importantly — how do you implement it without locking yourself out of your own systems?
Let's dig in.
What Is 5.10.5?
At its core, control 5.10.5 is about limiting who can connect to your systems using remote access protocols — specifically Telnet and SSH. These are the doors people use to log into servers remotely, and this control says you need to put restrictions on those doors.
Here's the thing most people miss: this isn't just about using strong passwords (though that's important). It's about controlling the source of the connections. Think of it like a VIP list for your server's front door.
The control typically requires you to:
- Define which IP addresses, networks, or subnets are allowed to initiate SSH or Telnet connections
- Block or deny access from all other addresses
- Document your rationale for what you've allowed
Telnet, by the way, is the older, insecure protocol that sends everything — including passwords — in plain text. Which means if you still have Telnet enabled anywhere in 2024, that's a problem. SSH is better (it encrypts traffic), but it still needs proper access controls Turns out it matters..
Why This Control Exists
Every server exposed to the internet without IP restrictions is a target. Once they find one, they try default credentials, common passwords, and brute-force attacks. Attackers run automated scans constantly, looking for open SSH ports. Restricting access to known, trusted IP addresses dramatically reduces this attack surface Worth keeping that in mind..
Why It Matters
Here's the uncomfortable truth: if your SSH daemon is listening on 0.0.0.Worth adding: 0 (all interfaces) with no IP restrictions, anyone with an internet connection can try to log in. And they will.
Automated attack tools scan for open SSH ports around the clock. We're talking millions of connection attempts per day across the internet. Most of these are noise — script kiddies running easy tools — but all it takes is one weak password or one unpatched vulnerability.
Some disagree here. Fair enough Small thing, real impact..
When you restrict SSH and Telnet access to specific IP ranges, you essentially make your server invisible to most of the internet. Attackers can't even reach the login prompt from their random IP addresses. It's not foolproof (attackers can spoof IPs or compromise allowed networks), but it's one of the simplest, highest-impact security controls you can implement.
Counterintuitive, but true.
The Real-World Consequences
I remember talking to an admin once whose company got hit through an exposed SSH port. Attackers used a credential stuffing attack with credentials from a previous data breach (yes, employees reused passwords). On top of that, they had a strong password — or so they thought. Within hours, the attackers had root access and deployed ransomware.
Would IP restrictions have stopped this? Probably. The attackers were operating from known malicious IP ranges that any decent restriction list would have blocked.
How to Restrict Telnet and SSH Access
Now for the practical part. Here's how you actually implement this control Most people skip this — try not to..
Step 1: Identify Which Services Need Restricting
First, figure out where Telnet and SSH are running. On Linux, that's usually:
- SSH: running as
sshdon port 22 - Telnet: running as
telnetdon port 23 (hopefully not enabled)
Run this to check:
ss -tlnp | grep -E ':(22|23)\s'
Or use netstat if that's what you have available.
Step 2: Configure Your Firewall
The most common approach is using the host-based firewall. On Linux, that's typically iptables, firewalld, or ufw. Here's how it works with each:
Using UFW (Ubuntu/Debian):
# Allow SSH only from specific IP
ufw allow from 192.168.1.0/24 to any port 22
# Deny everything else to SSH
ufw deny 22
Using firewalld (RHEL/CentOS):
# Add a rich rule for SSH from specific IP
firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.1.0/24" port port="22" protocol="tcp" accept'
# Reload to apply
firewall-cmd --reload
Using iptables directly:
# Allow SSH from trusted network
iptables -A INPUT -p tcp -s 192.168.1.0/24 --dport 22 -j ACCEPT
# Drop everything else
iptables -A INPUT -p tcp --dport 22 -j DROP
Step 3: Configure SSH Daemon Itself
You can also restrict access directly in the SSH daemon configuration. Edit /etc/ssh/sshd_config:
# Only allow specific users from specific IPs
AllowUsers admin@192.168.1.* deploy@10.0.0.*
# Or restrict by group
AllowGroup sshusers
# Disable root login (always a good idea)
PermitRootLogin no
# Use key-based authentication
PasswordAuthentication no
Then restart SSH:
systemctl restart sshd
Critical warning: Test your configuration before you log out of your current session. Open a new terminal and verify you can still connect. I cannot stress this enough — people lock themselves out all the time.
Step 4: Handle Dynamic IPs
This is where things get tricky. What if your legitimate users don't have static IP addresses? Maybe they're working from home, traveling, or using mobile networks.
A few options:
- VPN first: Require users to connect to a VPN first, then SSH only works from the VPN's IP range
- Jump hosts: Have a bastion host with stricter (or different) access controls, then allow SSH to internal systems only from that host
- Dynamic DNS with caution: Some solutions allow dynamic DNS updates, but this adds complexity and potential attack surface
- Certificate-based access: Combine IP restrictions with certificate authentication for defense in depth
Step 5: Disable Telnet Altogether
If Telnet is running anywhere on your systems, disable it. Now. It's 2024 — there's no legitimate reason to use Telnet in production.
# Check if telnet is enabled
systemctl status telnet.socket
systemctl status xinetd
# Disable it
systemctl stop telnet.socket
systemctl disable telnet.socket
systemctl mask telnet.socket
Common Mistakes
Let me tell you about the mistakes I've seen (and made myself):
Testing changes remotely and locking yourself out. This happens constantly. Always test from a second session before ending your current one. Keep a console or out-of-band access available.
Allowing "any" accidentally. I've seen configs where someone meant to allow a specific subnet but typed 0.0.0.0/0 by mistake. Double-check your CIDR notation.
Forgetting IPv6. You restrict IPv4 but leave IPv6 wide open. Make sure you're covering both protocols in your firewall rules.
Not documenting your rationale. Auditors will ask why you allowed specific IPs. If you can't explain it, you've got a problem Worth keeping that in mind..
Allowing too broad a range. "Allow from 10.0.0.0/8" might seem safe internally, but if that network spans multiple departments or buildings, you're probably allowing more access than you need.
Practical Tips
A few things that actually help in the real world:
Use a jump host. Have one hardened system that accepts external SSH connections, then only allow internal SSH from that host. This gives you one place to monitor, log, and restrict access Practical, not theoretical..
Implement fail2ban. Even with IP restrictions, you want to block repeated failed login attempts. Fail2ban automatically bans IPs that fail authentication too many times.
Log everything. Make sure your SSH logs are being captured and monitored. Look for authentication failures, especially from unexpected sources Still holds up..
Review quarterly. IP restrictions aren't a "set and forget" control. Review who's accessing what and whether those permissions still make sense.
Consider SSH certificates. If you're in a larger environment, SSH certificate authorities can provide more granular control than SSH keys alone.
FAQ
Does 5.10.5 require me to disable Telnet entirely?
Yes, in most compliance frameworks. Telnet transmits data in cleartext, including credentials. There's no scenario in 2024 where Telnet should be running on a production system Small thing, real impact. Surprisingly effective..
What if I need to access SSH from multiple locations with changing IPs?
Use a VPN. Have users connect to the VPN first, then SSH to your systems. Your SSH restrictions then only need to allow the VPN's IP range.
Can I use hostname-based restrictions instead of IPs?
Some SSH configurations allow it, but it's generally not recommended. DNS can be spoofed, and it adds complexity. IP-based restrictions are more straightforward and auditable.
What about cloud environments?
Cloud instances often have security groups or network ACLs that serve the same purpose. Make sure you're restricting at both the security group level and the host level for defense in depth.
Does this control apply to internal networks only?
No. While internal networks are lower risk, the control typically applies anywhere SSH or Telnet is accessible. Internal threats exist, and proper segmentation is still important Which is the point..
The Bottom Line
Restricting Telnet and SSH access is one of those controls that seems simple but has real teeth. It won't stop a determined attacker who compromises an allowed network, but it will stop the automated noise that hits every exposed server on the internet.
Some disagree here. Fair enough.
The implementation isn't complicated — it's mostly firewall rules and SSH daemon configuration. The hard part is thinking through your access patterns, documenting your rationale, and maintaining it over time Nothing fancy..
Start with the basics: disable Telnet, restrict SSH to known IPs, test your changes, and document everything. You can always refine from there And that's really what it comes down to..
Now go check which IPs are allowed to SSH into your systems. I'll wait That's the part that actually makes a difference..