I can login to my sudo account on CentOS 5.11 VPS (through the ssh keys) , but I have to reset root password and sudo user passwords (any of these two). Is it possible and how?


If you don't know the current password for the sudo user or the current root password and you don't have console access or some other web panel way to change the root password then you're screwed and should contact your service provider's support.


Yes, once you're connected as root, type passwd root, it will prompt you for the new password, and ask for a confirmation of it. After that the new password is the one you've type.

For sudo passwd, it's actually the user password itself, you will in this case need to change the user passwd, for example to change user "test" password, type as root passwd test.

  • My question wasn't explained well. I can login as sudo user only. Not as root. – Zvezda Mar 1 '16 at 10:40
  • And you don't know your own passwd if I understood well. Do you know what are you allowed to do with sudo ? You can try to become root with sudo su - but I doubt it to work. – Pierre-Alain TORET Mar 1 '16 at 10:44
  • sudo bash might also work to get a root shell. – Silent-Bob Mar 1 '16 at 10:45
  • You can also try sudo passwd or sudo passwd your_username, maybe they gave you the right to do it without password. Another way of achieving this would be to boot with a live cd, do a chroot in your root directory and then issue the passwd command for root. But I don't know about what this server/workstation is and if you can put it down for some time. – Pierre-Alain TORET Mar 1 '16 at 10:47
  • 1
    Contact your VPS hoster support and ask for a root password reset (maybe they have such an option in their web-interface, otherwise contact them). – Silent-Bob Mar 1 '16 at 11:31

Use the passwd program (as root):

passwd $username

Just replace $username with the desired username.

It will ask you for the new password and change it in the system ( /etc/shadow ).

  • Thanks for the downvote, stranger. Before OP edited his question my answer was correct. – Silent-Bob Mar 1 '16 at 11:34
  • The answer was right before editing my question in order to better explain it. – Zvezda Mar 1 '16 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.