Friday, January 5, 2018

Can't Login as Root? (Centos 5)

Please take note that this steps were done in full caution, and with responsibility for anything terrible that could happen..

Last month, I was contacted by a client informing me that he/she cannot log in to the server as root for the past 2 weeks. Obviously they contacted me because I was the person responsible for setting up their server back in August. and, as far as I can remember, I never made changes to the server..

I tried logging in with all the passwords that I can remember, but to no avail.. I requested to work via TeamViewer to have a look at the machine.. yes its a virtual machine.. then I restarted the server..

Only then I notice that there was this error -> no user root found!

So I start googling and found this site:
https://wiki.archlinux.org/index.php/reset_root_password#Using_GRUB_to_invoke_bash

I followed most of the steps, but in the end I can't use the command passwd to change the password.. and the root user was not root.. apparently when I checked the passwd file, the line for root was nowhere to be seen.. seems like the passwd file has been modified...

DO THIS AT YOUR OWN COST!

So what I did was, I edited the passwd file on the line that I suspected used to be root - rename it to root again - based on the passwd file on other servers, and save the damn file..

Afterwards, I used the passwd command to change to root password (hey it worked!) and I exited bash.. an error message(?) or a warning(?) came up

Kernel panic - attempted to kill

But I crossed my fingers and reboot the server anyway.. and Alhamdulillah.. everything worked fine!!

NOTES:

If I was going to edit any files, I should have used/mounted a live cd/iso on the vm.. but at that moment, the damage has been done..

after this I'll try to use a live cd..



No comments: