I’ve been trying to wrap my head around this for a while. So I somehow managed to goof up my root password and now I can’t access my remote server, when I login. I however, have sudo access through another user using SSH.

Therefore, I have root privileges, just that I can't seem to access the root login. So how can I reset the root password using root privileges from another user? Is it even possible?

EDIT: Could it be possible that my /etc/sudoers file is conflicting? Because each time I log in, it says ACCESS DENIED. I have both "root" and my other username in there.

  • Yes, if you are a sudo user (ALL privilege) then you can try sudo -i and enter normal user password. It will go to root prompt from there you can change root password. – max Jul 14 '16 at 4:05
  • 3
    Possible duplicate of resetting the root password in linux – Giacomo1968 Jul 14 '16 at 4:11
  • @max unfortunately that didn't work. When I try to SSH using root, it tells me it can't authenticate it. Any ideas? – RyanB Jul 14 '16 at 4:30
  • Two things: ssh user@ip and then sudo passwd root {enter new password twice} and retry if this fails, did ssh root@ip EVER work ? if not its likely that the remote system is /has been hardened and disallows ANY ssh root@ip actions I personally have my laptop set in this fashion. – linuxdev2013 Jul 15 '16 at 14:00

Become root: sudo su -

then: passwd

Also, if you want to ssh as root, check your sshd_config for PermitRootLogin. This is a security risk though, so it's better to login as a normal user and use sudo.

  • PermitRootLogin was set to NO. Maybe that's why I wasn't able to log in? – RyanB Jul 14 '16 at 4:52
  • That didn't work. I tried resetting the password using sudo passwd root and even though it updated successfully, it still says ACCESS DENIED. What could be the issue? – RyanB Jul 14 '16 at 6:32
  • After changing PermitRootLogin=YES did you restart the SSH service? – max Jul 16 '16 at 4:31

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.