Sudo password not required

Hi. My sudo password is not required anymore--maybe I did something wrong, maybe it resulted from some upgrade. I was wondering what to do? I have my home directory backed up to an external, so I can go nuclear if I need to. I figure it's kind of a big deal for your computer to not ask for a password that tells it that you are an administrator and to run the command you instruct--am I wrong about this?

Not an expert but if you somehow disabled root, which is NOT recommended this command in the terminal should reenable root.

Enable Root: sudo -i

if sudo is missing it can be reinstalled with this command:

apt-get install sudo

if this affects your user sudo rights give them back as root in the terminal.

usermod -a -G sudo (followed by < user name > but that hides it in the command in this post for some reason.

Generally you will need to reboot for these to take effect.

These commands are from my 'cheat sheet'.

1 Like
  1. Just verify that /etc/sudoers file does not contain NOPASSWD option. E.g. %sudo ALL=(ALL:ALL) NOPASSWD: ALL line in the mentioned file disables password authentication for any user and any command.
  2. Some people reported that their PAM (authentication) subsystem was misconfigured after upgrade. E.g. see Ubuntu 22.04: sudo not asking for password with empty sudoers.d and no "NOPASSWD" entry in /etc/sudoers - Ask Ubuntu

Good luck!

4 Likes

I'm afraid these statements are plain wrong.

  1. Ubuntu and Ubuntu Mate have root account disabled by default. That means that root account has no password and it is impossible to login into system using "name:password" challenge. Nor remotely, nor locally.
  2. Mentioned sudo -i command allows a user with proper sudo privilege to impersonate superuser and act in his name. No account becomes enabled then.
2 Likes

I was wondering what to make of this:

the file, /etc/sudoers.d/kdesu-sudoers

Defaults!/usr/lib/*/libexec/kf5/kdesu_stub !use_pty

Is this code okay?

Sorry, I do not know kde specifics.

/etc/sudoers.d/kdesu-sudoers

I use KDE, but on Arch Linux. Never seen that file before.

In Ubuntu 24.04, it's provided by the libkf5su-data package. Turns out it's harmless:

translation files for kdesu

As a sanity check, you could post your /etc/sudoers and /etc/sudoers.d/* files here and we can compare with the defaults. Maybe the output of id too just in case.

By the way, the topic is tagged as 22-04-jammy-LTS but the /etc/sudoers.d/kdesu-sudoers is not found for Ubuntu 22.04 "Jammy". Was that tag an error, or could your system be partially upgraded to 24.04?

1 Like

I don't think I have a partial upgrade. I do have kde wallet program.

kdesudoers

sudoers

I think that apt not having a stable cli is a big problem.

Hi, @Anthony_Craig :slight_smile:

You wrote:

If you're referring to the "WARNING: apt does not have a stable CLI interface. Use with caution in scripts.": that's a usual warning that appears when you run the "apt" command followed by a "pipe" operator and followed by another command - as you did with that sudo apt list --installed | grep "ubuntu-mate" command that you've correctly typed. You can see a discussion about this "WARNING", for instance, back in 2016, in the following answer in the "Ask Ubuntu" web site:

2 Likes

Your screenshot contradicts your original message. The sudo mechanism asks for your password. What does alarm you exactly?

2 Likes

Hi, @ironfoot Sometimes the sudo wasn't required--maybe I entered the password recent enough that it was not asked for again. I guess the attached files were okay? Is it surprising that I have kde on my system? I guess that's where the kdesudoers comes from--from the kde wallet (I'm not rich enough to even use that program, really).

You might want to mention how to open the sudoers file.

In that case, it's pretty normal that sudo remembers the password for about 15 minutes in the same terminal session. Nothing to worry about!

If you need stricter security, you can change the timeout by editing your sudoers file:

6 Likes