How to enable root access on Linux server

Root login over SSH can be required to carry out several operations and allow connection from other servers.

Enable root login over SSH:

1. With root login, edit the file sshd_config file located under /etc/ssh/sshd_config directory with your favorite file editor; vi or nano.

vi /etc/ssh/sshd_config

2. Go to the line that says PermitRootLogin yes, and remove the “#” sign in order to comment it out.

# Authentication:
#LoginGraceTime 2m
PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

3. Now save the file with ‘wq’ if using vi editor or ‘Ctrl + O’ & type ‘Ctrl + X’ to save & exit in nano editor.

4. Finally, restart the SSH server to amend the changes.

service sshd restart

You are now ready to connect to the server as root over SSH.