Enable SSH access for root.
🚀 One-Line Download & Execute :
To enable root SSH login on a Linux system, follow these steps :
- Log in to your server with an account that has sudo or root privileges.
- Set or confirm the root password if needed :
sudo passwd rootEnter and confirm the new root password.
- Edit the SSH daemon configuration file :
sudo nano /etc/ssh/sshd_config - Find the line containing PermitRootLogin. It may be commented out with a #. Change or add this line :
PermitRootLogin yes - Save the file and exit the editor.
- Restart the SSH service to apply the changes :
orsudo systemctl restart sshd
sudo service sshd restart - You can now log in remotely as root using SSH :
ssh root@your-server-ipEnter the root password when prompted.
Important Security Note :
Enabling root login over SSH is a security risk. It’s recommended to use normal user accounts with sudo privileges instead. If you enable root SSH login, consider using SSH key authentication and strong passwords to improve security.
This method applies to most Linux distributions, including Ubuntu, Debian, CentOS, Rocky Linux, and others. Some systems may use slightly different service names or editors, but the main steps remain the same.