LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-10-2020, 01:12 AM   #1
hacback17
LQ Newbie
 
Registered: Nov 2019
Posts: 12

Rep: Reputation: Disabled
Question su: Authentication token manipulation error


Hi everyone,
The code snippet works fine (that means it creates a user, sets a password) but when I try to login as the recently created user, it produces "su: Authentication token manipulation error" error. Please help me understand what's wrong.

Code:
#!/bin/bash

# This script creates a new user on the local system.
# You will be prompted to enter the username (login), the person name, and a password.

# The username, password, and host for the account will be displayed.

# Make sure the script is being executed with superuser privileges.

if [[ "${UID}" -ne 0 ]]
then
	echo 'Please run with sudo or as root.'
	exit 1
fi

# Get the username (login).
read -p 'Enter the username to create: ' USER_NAME

# Get the real name (contents for the description field).
read -p 'Enter the name of the person or application that will be using this account: ' COMMENT

# Get the password.
read -p 'Enter the password to use for the account : ' PASSWORD

# Create the account.
useradd -c "${COMMENT}" -m ${USER_NAME}

# Check to seeif the useradd command succeded.
# We don't want to tell the user that an account was created when it hasn't been.
if [[ "${?}" -ne 0 ]]
then
	echo 'The account could not be created.'
	exit 1
fi

# Set the password
echo ${PASSWORD} | passwd --stdin ${USER_NAME}

if [[ "${?}" -ne 0 ]]
then
	echo 'The password for the account could not be set.'
	exit 1
fi

# Force password change on first login.
passwd -e ${USER_NAME}

# Display the username, password, and the host where the user was created.
echo  #blank line
echo 'username:'
echo "${USER_NAME}"
echo
echo 'password:'
echo "${PASSWORD}"
echo
echo 'host:'
echo "${HOSTNAME}"
exit 0

Last edited by hacback17; 02-10-2020 at 01:24 AM.
 
Old 02-10-2020, 03:14 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,015

Rep: Reputation: 7340Reputation: 7340Reputation: 7340Reputation: 7340Reputation: 7340Reputation: 7340Reputation: 7340Reputation: 7340Reputation: 7340Reputation: 7340Reputation: 7340
exactly how did you try to login as the recently created user ?
 
Old 02-10-2020, 04:04 AM   #3
hacback17
LQ Newbie
 
Registered: Nov 2019
Posts: 12

Original Poster
Rep: Reputation: Disabled
Hi, I created a user 'amit', and tried to login as following:

Code:
[vagrant@localusers shellclass]$ su - amit
Password:
You are required to change your password immediately (ro
ot enforced)
Changing password for amit.
(current) UNIX password:
su: Authentication token manipulation error
 
Old 02-10-2020, 06:18 AM   #4
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
My guess is that su, or /etc/pam.d/su, does not support password renewal. It probably only allows switching the user ID.

Try logging in normally, for example ssh amit@localhost.

EDIT: On Centos 8, I can login and change the password with su. However, your distro's su implementation might not support this.

Last edited by berndbausch; 02-10-2020 at 06:24 AM.
 
Old 02-10-2020, 07:56 AM   #5
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 22,015

Rep: Reputation: 7340Reputation: 7340Reputation: 7340Reputation: 7340Reputation: 7340Reputation: 7340Reputation: 7340Reputation: 7340Reputation: 7340Reputation: 7340Reputation: 7340
Yes, probably you cannot use su if the password was marked as expired.
 
Old 02-10-2020, 11:33 AM   #6
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,738

Rep: Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222
My guess is that the password entered at the first login doesn't meet the minimum requirements for passwords on the system. i.e.; too short, mixed case, etc.
 
Old 02-10-2020, 04:04 PM   #7
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by scasey View Post
My guess is that the password entered at the first login doesn't meet the minimum requirements for passwords on the system. i.e.; too short, mixed case, etc.
Doesn't matter as the script is run by root.
 
Old 02-10-2020, 04:29 PM   #8
scasey
LQ Veteran
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.9.2009
Posts: 5,738

Rep: Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222Reputation: 2222
Quote:
Originally Posted by berndbausch View Post
Doesn't matter as the script is run by root.
Sorry. I meant the password entered at the su -, which then required a new password to be entered...although, presumably, that test was being done by su'ing from a different unprivileged user, as an su done by root wouldn't even ask for a password, afaik.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"passwd: Authentication token manipulation error" Neowulf Linux - Newbie 8 03-05-2014 04:01 PM
Authentication Token Manipulation Error manfernandez Linux - Security 10 06-06-2008 11:49 AM
passwd:Authentication token manipulation error jovie Linux - Security 3 05-10-2006 01:46 AM
passwd: Authentication token manipulation error jwholey Linux - Enterprise 4 05-10-2006 01:41 AM
authentication token manipulation error abuelmaati Linux - Newbie 3 02-04-2005 07:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration