LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   passwd: permission denied error when trying to update a user's password (https://www.linuxquestions.org/questions/linux-newbie-8/passwd-permission-denied-error-when-trying-to-update-a-users-password-4175593979/)

ProAm500 11-21-2016 01:51 PM

passwd: permission denied error when trying to update a user's password
 
Hi all. I just installed Ubuntu on a new machine and everything seemed to be going fine. I and a coworker were having some issues with a few things and have managed to lock-out a local admin (sudo?) account after unjoining an AD domain using realm while troubleshooting some McAfee issues were were having. I'm 99.9% certain that the password has not changed for the user. I have followed ALL the steps found here for resetting the password as root in recovery. When I try to run
Code:

sudo passwd USERNAME
I get the error:
Code:

root@HOSTNAME:~# sudo passwd USERNAME
passwd:Permission denied
passwd:password unchanged
root@HOSTNAME:~#

When I try to do the steps for the "The Drastic Measures", I notice that the shadow file does not show what would usually indicate an encrypted password for the user. Instead it looks like:
Code:

username:!:14920:0:99999:7:::
I have removed the exclamation point and still have issues. Even when I run passwd as root through recovery, I get a permissions denied error. As it stands right now, I can only log into the machine as root through recovery. I'm at a complete loss at this point and trying to avoid breaking down the machine and starting from scratch. Any help you guys can provide would be greatly appreciated.

snowday 11-21-2016 01:56 PM

Since you are already "root" there is no need to use "sudo" too. Try simply:

Code:

passwd USERNAME
(Where "USERNAME" is the actual username, obviously.)

Please note that the tutorial you are following didn't say to use "sudo" either.

vincix 11-21-2016 02:06 PM

@snowpine You are correct, but there's no reason for root not to be able to sudo. Just try it yourself. It's just redundant, but it has to work.

@OP What does /etc/pam.d/passwd look like? Do you encounter the same error when trying other commands that need privilege?

ProAm500 11-21-2016 02:51 PM

Quote:

Originally Posted by snowpine (Post 5633100)
Since you are already "root" there is no need to use "sudo" too. Try simply:

Code:

passwd USERNAME
(Where "USERNAME" is the actual username, obviously.)

Please note that the tutorial you are following didn't say to use "sudo" either.

I should have noted that I used sudo after trying without sudo first as sort of a "hail mary", neither worked.

vincix 11-21-2016 02:57 PM

Now that I think about it, are you sure the you've mounted the root partition as writable? Maybe that's the reason why you get permission denied, you might have only read permissions. That's an essential part of the recovery process: mount -rw -o remount /

ProAm500 11-21-2016 03:13 PM

Quote:

Originally Posted by vincix (Post 5633131)
Now that I think about it, are you sure the you've mounted the root partition as writable? Maybe that's the reason why you get permission denied, you might have only read permissions. That's an essential part of the recovery process: mount -rw -o remount /

Per the instructions in the the link in the OG post, I ran
Code:

mount -o remount,rw /
as root in recovery but no dice.

vincix 11-21-2016 03:21 PM

Maybe you should make sure that the system is actually mouting the right partition. Do you find the correct users in /etc/passwd, for instance?

ProAm500 11-22-2016 08:47 AM

Quote:

Originally Posted by vincix (Post 5633143)
Maybe you should make sure that the system is actually mouting the right partition. Do you find the correct users in /etc/passwd, for instance?

I made sure this morning that I ran the commands to mount the partition (which I also did yesterday while in root through recovery) first before trying some additional troubleshooting. Still issues. Here's what I found this morning:

When running /etc/passwd I got this:
Code:

passwd: Permission denied
passwd: password unchaged

I checked the permissions on passwd and got:
Code:

-rw-r--r-- 1 root root 1046 Nov 21 14:29 /etc/passwd
I tried to run /etc/shadow and got:
Code:

/etc/shadow: Permission denied
When I checked permissions on /etc/shadow I got:
Code:

-rw-r----- 1 root shadow 1310 Nov 21 14:29 /etc/shadow
From reading here, it should look more like this:
Code:

-rw------- 1 root root 823 Dec 7 19:59 /etc/shadow
This was all run as root in recovery. (As mentioned, that is the only way that I can log into the system at this point.)

If it comes to it, can I reinstall Ubuntu from DVD and sort of run a "recovery" without loosing all my settings, programs, etc. Almost like a refresh without starting from scratch?

vincix 11-22-2016 08:55 AM

I don't understand what you mean by "running" /etc/shadow. Shadow is a file. What did you run exactly?
First, let me get this straight, you haven't been able to change the root password, right? Are have you only tried to change the password for the admin user?

You could try changing the password for the root and then boot normally into Ubuntu, log in with root, change the admin password and disable root (although, to be honest, there's no reason not to use the root directly, as it's done in Red Hat-based distros, but that's another subject).

It doesn't really make much difference if /etc/shadow has the read permission or not. This is how it looks on Centos 7:
---------- 1 root root 1482 Oct 31 00:02 /etc/shadow

So I wouldn't worry about that. That's not the problem.

By the way, please tell us exactly what version of Ubuntu you're running.

vincix 11-22-2016 09:04 AM

I'm thinking now that the problem might be related to the ldap authentication. Maybe when you invoke the passwd command, it's not really using /etc/shadow but some other file (trying to connect to the DC, etc.)
What does /etc/nsswitch.conf say?

ProAm500 11-22-2016 11:00 AM

Quote:

Originally Posted by vincix (Post 5633365)
I don't understand what you mean by "running" /etc/shadow. Shadow is a file. What did you run exactly?
First, let me get this straight, you haven't been able to change the root password, right? Are have you only tried to change the password for the admin user?

You could try changing the password for the root and then boot normally into Ubuntu, log in with root, change the admin password and disable root (although, to be honest, there's no reason not to use the root directly, as it's done in Red Hat-based distros, but that's another subject).

It doesn't really make much difference if /etc/shadow has the read permission or not. This is how it looks on Centos 7:
---------- 1 root root 1482 Oct 31 00:02 /etc/shadow

So I wouldn't worry about that. That's not the problem.

By the way, please tell us exactly what version of Ubuntu you're running.

Quote:

Originally Posted by vincix (Post 5633366)
I'm thinking now that the problem might be related to the ldap authentication. Maybe when you invoke the passwd command, it's not really using /etc/shadow but some other file (trying to connect to the DC, etc.)
What does /etc/nsswitch.conf say?

I should clarify, when I say "run" I literally mean "typed "x" in the terminal and hit enter". I'm running Ubuntu 16.04. Machine was part of a Active Directory domain, LDAP was not used. We were trying to install McAfee on the system and was having some issue so "unjoined" using realm (the same method I used to join the domain). There were two accounts on the machine. My domain account and a local account. Domain obv. doesnt work but the local account also no longer works (even though my domain acct still sappears to be possibly cached, I can't log in using that account). I can only log in via root from recovery. When I "run" /etc/nsswitch.conf I get the following:
Code:

bash: /etc/nsswitch.conf: Permission denied
I checked permissions on it and got:
Code:

-rw-r--r-- 1 root root 575 Nov 14 09:37 nssswitch.conf.

Emerson 11-22-2016 11:03 AM

Why are you trying to run a text file? :confused: You sure you are up to the task before you?

ProAm500 11-22-2016 11:13 AM

Quote:

Originally Posted by Emerson (Post 5633413)
Why are you trying to run a text file? :confused: You sure you are up to the task before you?

To clarify and as stated above, I don't literally mean "run" as in "run a program", I do literally mean "type 'x' in the terminal and hit enter".

vincix 11-22-2016 02:04 PM

Quote:

Originally Posted by ProAm500 (Post 5633417)
To clarify and as stated above, I don't literally mean "run" as in "run a program", I do literally mean "type 'x' in the terminal and hit enter".

What does 'x' do? Why are you doing this?

When I ask you what /etc/nsswitch.conf looks like, and I'm no expert in linux, I think it's implied that one would understand running cat /etc/nsswitch.conf, or less or more or whatever command you're comfortable with.

goumba 11-22-2016 02:19 PM

Quote:

Originally Posted by ProAm500 (Post 5633410)
I should clarify, when I say "run" I literally mean "typed "x" in the terminal and hit enter".

Quote:

Originally Posted by ProAm500
To clarify and as stated above, I don't literally mean "run" as in "run a program", I do literally mean "type 'x' in the terminal and hit enter".

And yet that's exactly what you are doing when you do something like type "/etc/shadow" and press enter - you are trying to run it as a program. Those files are text files, and just like in any other operating system you must use another program to view them.

The only exception to the rule are scripts, but we're not dealing with those here.

Try:
Code:

cat /etc/passwd
Code:

cat /etc/shadow
Code:

cat /etc/nsswitch.conf
from man cat (get familiar with man:
Code:

NAME
      cat - concatenate files and print on the standard output

SYNOPSIS
      cat [OPTION]... [FILE]...

DESCRIPTION
      Concatenate FILE(s) to standard output.

      With no FILE, or when FILE is -, read standard input.



All times are GMT -5. The time now is 08:43 AM.