Question

I am working on an ubuntu server with a colleague and we were not provided a sudo password. (they told us that they forgot the password)

We were asked to recover the sudo password. Through our search on the net found out that we need to reboot into recovery mode to do so but we don't know how to get into recovery mode through ssh. Any idea of how is this possible or any other ideas for recovering the sudo password?

PS. We do have root access through ssh.

Thanks in advance. Your time is indeed valuable and appreciated by us.

  • Bookies
Was it helpful?

Solution

We changed the password using the root access sudo passwd command.

Thanks everyone.

OTHER TIPS

A few assumptions:

First of all, normally, on Ubuntu, you can't log in as root; as the login-shell is disabled in /etc/passwd. Also, many times, you can't login as root over SSH - as root login is not permitted.

So, if you can login as root, it means the root login shell is enabled, there is a root password (normally it's not set in /etc/shadow on Ubuntu as the acount is disabled anyway), and SSH permits you to login as root:

Try the command "visudo". This starts up vi to edit the file /etc/sudoers (sudo configuration file). See:

http://www.sudo.ws/visudo.man.html

If you don't know how VI works, see for example:

http://www.unix-manuals.com/tutorials/vi/vi-in-10-1.html

before visudo closes and saves the file, it checks the file for errors. If there's errors in the file, it doesn't save it. This way, you'll never lock yourself out of being able to use sudo.

Second of all, there is not such a thing as a "sudo password". It's either the users own password, or the root password.

If the option "rootpw" is set in /etc/sudoers (which you edit with visudo), every user has to use the root password to use sudo.

If it's not set in /etc/sudoers, every user has to use their normal "account-password" to use sudo.

For a description of the /etc/sudoers semantics, search for "man sudoers" on the web and you'll find the manual.

Especially the examples at the end of the manual are very useful.

If you need to reset / rewover a sudo password, the only way this can be done AFAIK is to use "passwd [user]", to reset their account login, which is stored in /etc/shadow, as this is the password sudo uses.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top