Score:0

Unable to remove root password for Ubuntu Bionic OS

uz flag
IoT

I have a system with Linux Ubuntu 18.04.5 LTS (Bionic Beaver) and one user account (root). I can access the system either with a console or an Ethernet connection. Over a console, I have no problem at all and I just need to type root to log in. However, when I try to access through SSH, the system keeps asking for a password even though the root account is passwordless. I executed the following commands to give root user access without a password but it did not help.

sudo sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
sudo service ssh restart

So I gave the root user a password using passwd command and now I can access my system through SSH.

Now, I am trying to remove the root password to reset the system to its original state. So I executed passwd -d root which returned passwd: password expiry information changed. However, when I try to login again using the console the system asks for both user name and the password of the root account.

I searched on the Internet and it seems just executing passwd -d root is sufficient to make the password empty. So I created a temporary user account with sudo access. Using this account, I tried to remove the root password, but again it did not work i.e. the system keeps asking for the root password and without it, I cannot log in.

hr flag
What exactly do you mean by "not able to do so" - what happens, exactly? Does the `passwd -d root` command return an error? Does the shadow file not change? Are you running the command from an actual root login, or using one of your sudoers?
uz flag
IoT
@guiverc I am using Ubuntu 18.04.5 LTS, sorry it was a typo
terdon avatar
cn flag
Why would you _ever_ want to allow root to ssh into a system connected to the internet? That is just asking for trouble. Why not use the normal approach of having a regular, non-root user who can ssh and then you can become root with `sudo -i` after logging in?
uz flag
IoT
@steeldriver `passwd` does not return any error but it does not have any effect on the root account. I am still prompted to enter the password. I am executing the command from the actual root login and I tried to change it from the other temporary sudoer account as I mentioned but still, I am always prompted to enter the password.
hr flag
"still prompted" doesn't mean the password wasn't deleted. SSH will still try any available authentication methods.
uz flag
IoT
@steeldriver I cannot log in to the system using the console without entering a password which was not the case at the beginning.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.