DEV Community

Cover image for Secure SSH by Using a Restricted User: Smarter Linux Hardening
Richard Chamberlain
Richard Chamberlain

Posted on

Secure SSH by Using a Restricted User: Smarter Linux Hardening

Here's a shortened version of your article tailored for platforms like dev.to and Medium, designed to tease the full content while encouraging users to visit your site.


🔐 Harden Your SSH: The Case for Using a Restricted User

SSH is the lifeline for managing Linux systems—but with great power comes great risk. If your administrative account is exposed over SSH, you're giving attackers a direct shot at your most critical assets.

That’s why I’ve adopted a simple but powerful security pattern:

Login with a restricted user
🔒 Switch to admin only after connecting

In this post, I explain:

  • Why using two separate user accounts improves security
  • How to configure a restricted shell (rbash)
  • Techniques to limit executable commands
  • Whether this is overkill—or just smart Linux hardening

Here's a quick preview of the setup:

# Create restricted shell
sudo usermod -s /usr/bin/rbash richard

# Allow only safe commands
sudo mkdir /home/richard/.bin
sudo ln -s /bin/ls /home/richard/.bin/ls
Enter fullscreen mode Exit fullscreen mode

This strategy significantly reduces your attack surface, even if a laptop or SSH key is compromised.


👉 Want the full walkthrough?
Read the complete guide here: sebostechnology.com


Need Linux expertise? I help businesses streamline servers, secure infrastructure, and automate workflows. Whether you're troubleshooting, optimizing, or building from scratch—I've got you covered.

📬 Drop a comment or email me to collaborate. For more tutorials, tools, and insights, visit sebostechnology.com.

Heroku

Deploy with ease. Manage efficiently. Scale faster.

Leave the infrastructure headaches to us, while you focus on pushing boundaries, realizing your vision, and making a lasting impression on your users.

Get Started

Top comments (0)

Postmark Image

"Please fix this..."

Focus on creating stellar experiences without email headaches. Postmark's reliable API and detailed analytics make your transactional emails as polished as your product.

Start free

Join the Runner H "AI Agent Prompting" Challenge: $10,000 in Prizes for 20 Winners!

Runner H is the AI agent you can delegate all your boring and repetitive tasks to - an autonomous agent that can use any tools you give it and complete full tasks from a single prompt.

Check out the challenge

DEV is bringing live events to the community. Dismiss if you're not interested. ❤️