How to enable root login

February 1, 2018 12k views

I dont know how to get access to it
and the article didnt help me

it just said login as root but i cant because its denied
and i dont know how to enable it.
i dont know how to get access to the console to enable ROOT

7 Answers

You can enable the root login as follow:

echo “PasswordAuthentication yes” >> /etc/ssh/sshdconfig
echo “PermitRootLogin yes” >> /etc/ssh/sshd
service sshd restart

Pablo Silva

Can you describe more about it. where you want to enable is it ssh?

  • i cant login as root. and i want to enable root login. and i dont know how to access that console to enable root login


Root login over ssh can be enabled by the doing following steps,

Login as a root user. use any text editor, here i am using vim editor.

vim /etc/ssh/sshd_config

uncomment the line below line

PermitRootLogin yes

Then restart the sshd service. That’s it. Let me know if you face any issues.

  • how can i login as a root user if i get denied?

    • There are two options,

      1. Physically you have to login to server ( means in the console ) and change the ssh configurations.
      2. Login as non root user account over ssh then login as root and make changes.

      If doesn’t help, Provide the details exactly where and how your are trying to login. How you created this server? OS details information ?


      • i just made the Droplet like 2 days ago… i want to login as root but i cant… and how can i login as non root user? i typed in the host/ip on putty and saved it. then it opens console. and it says. Login as:

        and i typed in my root user name and password and it says access denied

        and i dont know how to access the root enable console
        thats what i need help with

This doesn’t seem to work for me. Root login only seems to work from web console, not from remote console.

I have the same problem - I can login with a public key, but I cannot run sudo. I have reset my root password and it has been emailed to me, but since passowrd login is disabled I cannot use this password to login as root/sudo. There seems to be a little problem in communication here, I guess?

This will happen if you setup key-based authentication when creating the droplet, and then you regenerate a key, switch machines, or some how lose the key you used when creating the droplet.

To get around this you can take these steps (assumes ubuntu 16.0.4 + droplet, but you can google the command for your flavor):

  1. login to digital ocean dashboard
  2. find your droplet and click on it
  3. On the left menu click “Access”
  4. Click on the blue “Launch Console” button
  5. Login to your server as your root user
  6. Edit sshd_config to allow PasswordAuthentication vim /etc/ssh/sshd_config Make sure the line PasswordAuthentication yes is in the file and uncommented
  7. Restart the ssh service systemctl restart ssh
  8. Now you can ssh via UN/PW from a remote machine

I would recommend once you’ve done this, immediately add your public key to the appropriate authorized_keys file and return sshd config to PasswordAuthentication no

Have another answer? Share your knowledge.