DEV Community

Wycliffe A. Onyango
Wycliffe A. Onyango

Posted on

100 Days of DevOps: Day 3

SSH Hardening: Disabling Direct Root Login

To disable direct root login, the SSH daemon configuration file, /etc/ssh/sshd_config, is edited. The PermitRootLogin directive is then set to no.

PermitRootLogin no
Enter fullscreen mode Exit fullscreen mode

The SSH service is then restarted to apply the changes.

sudo systemctl restart sshd
Enter fullscreen mode Exit fullscreen mode

Purpose and Context

Restricting direct root SSH login is a crucial security practice that strengthens a system's defense against unauthorized access.

Enhanced Security

By disabling direct root login, you force administrators and users to log in with a standard user account first. This adds an essential layer of security, as any successful brute-force attack would need to guess both the username and password, not just the password for a known username like root.

Improved Accountability

When everyone logs in with their own named account, it creates a clear audit trail. This makes it easy to track who made what changes and when, which is vital for security monitoring, compliance, and troubleshooting. If direct root access is allowed, it's difficult to tell which user was responsible for specific actions.

Controlled Privilege Escalation

Users who need to perform administrative tasks can still gain root privileges by using commands like sudo after logging in. This method provides better control and logging of privileged actions, ensuring that administrative tasks are performed deliberately and are properly recorded.

Top comments (0)