- 0 Comments
- Blog
Enable Root
SSH Login
- 5 min read
- Linux, Dedicated Server
When your KwikServer VPS or Dedicated Server is first provisioned, root SSH login is disabled by default as a security measure. This is standard practice across all major Linux distributions. While it protects your server from automated brute-force attacks, there are many valid reasons to enable direct root access — such as running automation scripts, setting up control panels like cPanel or DirectAdmin, or simply streamlining your admin workflow. This guide walks you through enabling root login safely and correctly in just a few minutes.
Why Is Root Login Disabled by Default?
The root account is the most powerful user on any Linux system. It has unrestricted access to every file, process, and configuration, which also makes it a primary target for automated brute-force attacks. To reduce risk, most cloud images and Linux distributions disable direct root SSH access by default. Instead, you receive a sudo-enabled non-root user (such as ubuntu, admin, or centos) to log in with, and you escalate to root only when necessary.
Enabling root login is completely safe when combined with the right security measures, which are covered at the end of this guide.
Before You Begin
Have the following ready before making any changes to your server:
Step-by-Step: Enable Root SSH Login
The core process is the same across all major Linux distributions. You will edit one line in the SSH daemon configuration file, then restart the SSH service.
Connect to Your Server via SSH
Log in using your existing non-root user. Replace the placeholders with your actual credentials:
ssh your_user@your_server_ip # Example for a typical Ubuntu server: ssh ubuntu@203.0.113.10
Open the SSH Configuration File
The SSH daemon configuration lives at /etc/ssh/sshd_config. Open it with elevated privileges:
sudo nano /etc/ssh/sshd_config
vi or vim instead of nano if you prefer.Find and Update the PermitRootLogin Setting
Search for the line containing PermitRootLogin. By default it looks like one of these:
# PermitRootLogin prohibit-password # PermitRootLogin no
Remove the # and change the value to yes:
PermitRootLogin yes
Ctrl + W to search, Ctrl + X to exit, then press Y and Enter to save.Restart the SSH Service
Apply your changes by restarting the SSH daemon:
# Ubuntu 20+, Debian, AlmaLinux, CentOS sudo systemctl restart sshd # Older Ubuntu / Debian systems sudo service ssh restart
Set a Root Password (If Not Already Set)
Many cloud images lock the root account by default (no password assigned). Set a strong password with:
sudo passwd root
Use at least 16 characters with a mix of letters, numbers, and symbols.
Full Commands by Operating System
Here are the complete command sequences grouped by Linux distribution for quick reference:
# 1. Open SSH config file sudo nano /etc/ssh/sshd_config # 2. Find and update: # PermitRootLogin prohibit-password # Change to: PermitRootLogin yes # 3. Save: Ctrl+X → Y → Enter # 4. Restart SSH sudo systemctl restart ssh # 5. Set root password (if not set) sudo passwd root # 6. Verify SSH is running sudo systemctl status ssh
# 1. Open SSH config file sudo nano /etc/ssh/sshd_config # 2. Find and update: # PermitRootLogin no # Change to: PermitRootLogin yes # 3. Save: Ctrl+X → Y → Enter # 4. Restart SSHD sudo systemctl restart sshd # 5. Set root password (if not set) sudo passwd root # 6. Verify SSHD is active sudo systemctl status sshd
Verifying the Change
Open a new terminal window (keep your original session open) and connect as root to verify everything is working:
ssh root@your_server_ip
A successful connection confirms root login is enabled. If you receive “Permission denied,” verify that you saved the config file correctly and restarted the SSH service. On Ubuntu 22.04 and later, also check /etc/ssh/sshd_config.d/ for any files that may override your setting.
Security Best Practices After Enabling Root
Enabling root login is a significant change. Follow these steps to maintain a secure server:
Use SSH Key Authentication
SSH keys are far more secure than passwords. Once your key is configured, disable password authentication entirely:
PermitRootLogin yes PasswordAuthentication no PubkeyAuthentication yes
Change the Default SSH Port
Moving SSH off port 22 dramatically reduces automated scan traffic and brute-force attempts:
Port 2222 # Any unused port above 1024
Install Fail2Ban
Fail2Ban monitors your logs and automatically bans IPs after repeated failed login attempts:
# Ubuntu / Debian sudo apt install fail2ban -y && sudo systemctl enable --now fail2ban # CentOS / AlmaLinux sudo yum install fail2ban -y && sudo systemctl enable --now fail2ban
Enabling root login is not inherently dangerous — running an unmonitored, unpatched server is. With proper security measures in place, root access simply makes server administration faster and more direct.
Kwik Server
Frequently Asked Questions
sudo systemctl restart sshd; (2) the root account has no password — run sudo passwd root; (3) on Ubuntu 22.04+, check /etc/ssh/sshd_config.d/ for override files that may be overriding your change.prohibit-password allows root login only via SSH key pairs — passwords are rejected. yes allows root login via both SSH keys and passwords. If you have SSH keys configured, prohibit-password is the more secure option for production servers./etc/ssh/sshd_config, change PermitRootLogin yes to PermitRootLogin no, then restart SSH with sudo systemctl restart sshd.