How to Enable Root Account in Kali Linux

How to Enable Root Account in Kali Linux

Since Kali Linux v.2020.1 release, the developers of Kali decided that due to usage of the Penetration Testing Distribution for day-to-day use [an unforeseen direction for the distro], as well as the fewer and fewer requirements for running Kali as ROOT, there was need to change the long-used everything-as-root” security model. The changes that were made were amongst others to DISABLE the root user account and hence the long-used “user::password“:

DEPRECATED root::toor 
ACTIVE/CURRENT kali::kali

Since then you have to go make configuration changes to Enable the by-default Disabled ROOT account. Lucky for Kali Linux users, you don’t have to perform the configuration changes manually. Instead, you just need to install a Kali package through the inbuilt package manager, and as it gets installed and unpacked, configurations are automatically made to make all mandatory changes to Enable the root account.

login-root-apt-show-thetqweb

NOTE:// The above command is run from a sudo user’s (thetqweb) account. As this user, the root account is switched to on Terminal and used to perform this and all other commands before logging off and logging onto the root user. It is at this point that the contents of the shadow file are viewed, and a grep done on specifically the root user’s shadow file contents.

Interestingly, the ROOT user’s shadow file show that the ROOT user is inactive/disabled, a fact deduced from the fact that the contents of the shadow file only contain an exclamation mark (!) – a representation of emptiness. In simple terms, the password of the ROOT user has never been set.

login-root-inactive-thetqweb

[Activating/Enabling the ROOT user account]

To install the activate/enable ROOT account package, run the following command [NOTE:// to avoid avoidable problems, run them as root by switching to that user];

sudo su -
apt-get install kali-root-login

login-root-apt-get-install-thetqweb

 

The next two commands are used:- to set the password for the ROOT user [passwd]; and to print the line containing the shadow of the ROOT user [cat && grep] respectively.

passwd
cat /etc/shadow | grep "root"

login-root-passwd-thetqweb

The last command above now shows that the ROOT user’s shadow has some content, unlike previously, when it was empty (represented by an exclamation, “!“) after running the exact command. This implies that the ROOT account password is now set, and you are good to go!

NOTE:// If you DO NOT set the root user’s password before logging out of the current account (thetqweb) and logging into the root account, you will never get access or log into the account, simply because there is no shadow content to decrypt and compare to whatever you enter in the password field. And NO, you CANNOT use the current user’s password as the ROOT user’s password. There unfortunately is NO WAY around setting the ROOT user’s password!

At this point, before proceeding, LOG OUT or SWITCH USER!

23

[Proof of Concept (PoC)]

To prove that we now can login as the ROOT user, below are some commands to run;

whoami
cd ~
ls /root

login-root-poc-thetqweb

whoami” prints the username of the currently logged in user.
cd ~” changes the directory to the HOME directory of the currently logged in user.
ls /root” lists the contents of the ROOT user’s HOME directory.

The last two commands cannot be run without “sudo” privilege escalation command or without throwing a “permission denied” error from a normal user account, which proves access (and most importantly login to the ROOT user’s account)!

 

How to Enable Root Account in Kali Linux
Kali Linux | thetqweb