How to Disable SSH Root Login in Linux?
Last Updated :
28 Apr, 2025
SSH or secure shell is a network protocol established between two computers on a network to communicate with each other and share data. This protocol is useful in the case of remote access to the machine. SSH makes the work easy and accessible anywhere. Here we will see how to disable SSH Root Login in Linux.
Why Disable SSH Root Login?
Disabling SSH root login reduces the attack surface by preventing direct root access, a prime target for brute-force attacks and limiting potential damage from compromised accounts.
1. Root is Hacker’s
The root account is the “admin” or “boss” of your Linux machine. They can do:
- Delete or modify any file (even system-critical ones!).
- Install malware, ransomware, or spyware.
- Create secret backdoors for future attacks.
A hacker with root access can:
- Wipe your entire server in seconds with
rm -rf /
.
- Steal sensitive data (passwords, emails, credit card info).
- Use your machine to attack other computers.
2. Brute-Force Attacks
Brute-force attacks are like a robot trying every possible combination to guess your password.
- Default username: The username “root” exists on every Linux machine. Hackers don’t need to guess the username—they already know it!
- No login limits: Without protections, bots can try thousands of password guesses per hour.
3. Limit Damage
Even if a hacker breaches your system, disabling root SSH login acts like a firewall between them and total destruction.
Without root access, hackers can’t:
- Install malicious software system-wide.
- Access files outside the compromised user’s permissions.
- Change critical system settings (network, security, etc.).
Installation of Openssh-server and Openssh-client
The client version is installed on the system if the requirements are only to connect to any available server over the network.
#sudo apt install openssh-client

openssh-client installation
The server version is installed on the system if the requirement is to make the system available to different ssh clients all over the network.
#sudo apt install openssh-server

openssh-server installation
Edit SSH access
Before making changes, check if the SSH server is active:
# sudo service ssh status

ssh status
Disable root ssh login:
# sudo gedit /etc/ssh/sshd_config

open config file command
The configuration file:

Permission is password protected
Change this “prohibited-password” to “no“:

Permit no
Now save the file and restart the ssh service using the below commands:
# service ssh restart

restart ssh service
Now you have successfully disabled the accessibility of root via ssh protocol.
Verify SSH Root Login Is Disabled
Verifying that you’ve successfully disabled root login is like testing a lock after changing it
Step 1: Find Your Server’s IP Address
First, you need your computer’s IP address
hostname -I
Step 2: Try Logging In as Root
Open a terminal on another computer (or your local machine) and type:
ssh root@your-server-ip
If you see the error like this Permission denied (publickey,password) than your root login is disabled.
Conclusion
Disabling SSH root login is like putting a padlock on your computer’s “admin account” door. Hackers love targeting the root user because it’s the master key to your entire system—they can delete everything, steal secrets, or turn your machine into a hacker tool. By blocking root access over SSH, you’re forcing hackers to guess both a username and a password, which is way harder.
Similar Reads
How to Disable Unlock Login Keyring in Linux
The login keyring in Linux is a security feature that stores sensitive information like passwords and encryption keys. It ensures your system is secure by requiring authentication to access stored credentials. However, it can sometimes prompt users for a password when the desktop environment starts,
5 min read
How to Block or Disable Normal User Logins in Linux?
Here we will see how to block or disable normal user logins in Linux. This is a good idea to prevent Normal users from connecting to your system. We will see how to block Normal user logins using /etc/nologin file. We are going to tell the users that what is actually happening by showing them a mess
2 min read
How to Disable IPv6 in linux?
In this article, we will discuss how to disable IPv6 in Linux. We can achieve this using sysctl. What is IPv6? IPv6 stands for internet protocol version 6, which is the latest version of the internet protocol. What is the Internet protocol? Internet Protocol (IP) is the protocol or set of rules by w
2 min read
How to Enable and Start SSH on Kali Linux
Secure Shell (SSH) is a protocol that provides a secure way to access a remote computer. It allows you to remotely log in to a system and execute commands as if you were sitting at the console. In this guide, we will explain how to enable and start SSH on Kali Linux, a popular Linux distribution use
5 min read
How to change the default SSH port in Linux
SSH (Secure Shell) is a network protocol used to securely connect to the remote server where the data between the server and client is transferred in an encrypted format. In the world of Linux system administration and security, one essential practice is changing the default SSH port. This article w
7 min read
How to Root in Kali Linux?
Every Linux Distribution comes up with a dedicated account service where all the Administrative Privileges of Linux are kept. And the Debian Linux Distribution, Kali Linux is not also different from that. If you want to get all the Administrative Abilities in Kali Linux, you have to perform Root in
4 min read
How to Disable Input in JavaScript ?
Disabling input fields in JavaScript is a common task when you want to restrict users from interacting with specific form elements. This can be useful in various scenarios, such as preventing modifications to fields that are conditionally locked or ensuring certain inputs are controlled programmatic
2 min read
How to Disable Auto Login in Ubuntu
In Ubuntu, when the user logs in, the system can be configured to automatically log in without requiring a password. This feature is convenient for single-user systems or in situations where security is not a primary concern. However, there are cases where you may want to disable auto-login to enhan
4 min read
How to Find All Failed SSH Login Attempts in Linux System?
By monitoring failed SSH login attempts in Linux, a system administrator can easily maintain the security of the Linux System. Every time a user tries to log into a Linux System using SSH whether it is a successful attempt or a failed one, it is recorded as an SSH login attempt in the records of the
5 min read
How to Change Root Password in Kali Linux?
Securing your Kali Linux system is crucial for protecting sensitive data and maintaining the integrity of your environment. One of the fundamental aspects of system security is regularly changing the root password. The root account in Linux has superuser privileges, making it a prime target for atta
5 min read