LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-23-2015, 05:59 PM   #1
dcarrington
Member
 
Registered: Dec 2011
Distribution: RHEL, CentOS, Ubuntu
Posts: 61

Rep: Reputation: 2
Problems with chpasswd


I'm not sure what I'm doing wrong...everything I've found indicates that I'm doing this correctly.

I have a file, password.txt, with the following contents:

Code:
root:Password1
I run 'chpasswd < password.txt' and I get no errors. When I run 'll /etc/shadow' I can see the timestamp has been changed on my shadow file.

My previous password no longer works, but when I try to log in as root using the new password, it fails.

Code:
$ su -
Password:
su: incorrect password

What am I missing?
 
Old 04-23-2015, 06:29 PM   #2
dcarrington
Member
 
Registered: Dec 2011
Distribution: RHEL, CentOS, Ubuntu
Posts: 61

Original Poster
Rep: Reputation: 2
I've found a workaround that looks like it will work, but I'm still confused as to why my chpasswd command doesn't work properly.

The workaround is to change the password.txt file to contain ONLY the password and then run

Code:
cat password.txt | passwd --stdin root
That seems to work correctly.
 
Old 04-23-2015, 06:36 PM   #3
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196
Not sure why chpasswd is not working, I have never used it. But you might check that the default encryption method is defined in the environment variables or in /etc/login.defs.

But I am curious why you need to use the password from a file if only changing the root password?

chpasswd man page states that it is intended for bulk processing of many user passwords, and passwd would be much easier used without cat-ing the file to stdin. Which is not to say that either should not work this way for a single password.

Last edited by astrogeek; 04-23-2015 at 06:39 PM.
 
Old 04-23-2015, 06:46 PM   #4
dcarrington
Member
 
Registered: Dec 2011
Distribution: RHEL, CentOS, Ubuntu
Posts: 61

Original Poster
Rep: Reputation: 2
Mainly because I have to change the root password on about 160 servers using a remote command function from Red Hat Satellite.

Unless there's a better way to do it, but we don't have Puppet or Ansible or any of those tools that could probably make this a lot easier.

Thanks for the reply!!
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Opewebmail with chpasswd kmamunbd Linux - Software 5 05-05-2010 02:36 PM
chpasswd command in UNIX bhandu Linux - General 1 06-08-2007 12:56 AM
Use chpasswd for passwords more than 8 characters ? artak_am Linux - General 1 08-09-2004 03:30 AM
CHPASSWD Help! Shadow File! clintonm9 Linux - Software 3 04-17-2004 09:15 AM
Problems installing Chpasswd!! RKris Linux - Software 1 05-25-2002 10:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 04:28 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