Wednesday, November 30, 2016

Recover Webmin's root pasword



There are cases where you don't have root password and can't login to webmin. Like the one i came across AWS RedHat 7 instance recently, AWS doesn't provide you root password for security reason. And you need admin login for webmin.

Also, in Ubuntu by default, root password is disabled, and you won't be able to log in to the Webmin webpage, as the Webmin root login will be disabled too. To fix this, you need to manually change the Webmin root password.

You can do this in one of two ways:

Procedure 1

After you perform # apt-get install webmin or yum install webmin ,you have to do the following:

Find your webmin binary install directory and webmin configuration directory.
If you don't know where it is, you can find it by running:
$ locate changepass.pl or $ sudo find / -name changepass.pl
$ #and
$ locate miniserv.conf

Then follow these instructions to change the password. Change your working path to the webmin binary install directory and then run changepass.pl:
$ cd <webmin-install-dir>
$ sudo ./changepass.pl <webmin-config-dir> root <newpassword>
Note this ONLY changes the webmin root login password and does not change the your 'real' root password.

Procedure 2

Get your encrypted password from /etc/shadow.

For example, the following command will output the password to the screen:
$
sudo grep your_username /etc/shadow |cut -f2 -d:

Next we edit this file:
$sudo vi /etc/webmin/miniserv.users
Note: you will need superuser rights to save it
Replace the asterisk in the first line with the password you aquired from /etc/shadow, so that the line looks something like this: 

root:$1$e/9mjoasd$asdasljjwynSD42

Save the file and exit the editor after that.

Restart webmin with this command:

$sudo /etc/init.d/webmin restart
After that, you can go to https://localhost:10000/ in your web browser and login using root as the username and the password of your non-root user.

Ref: https://help.ubuntu.com/community/WebminWithoutARootAccount

No comments:

Post a Comment