Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 344
  • Last Modified:

User account creation

How would I create a user from the command line with a password that will never expire?
0
traderhank1
Asked:
traderhank1
1 Solution
 
gtkfreakCommented:
Type the following at command prompt to see the details of the command for adding users:
# man useradd
0
 
traderhank1Author Commented:
that wasn't "exactly" helpfull.
0
 
steveb3210Commented:
Hello,

You can set the password aging limits  by editing /etc/login.defs

You can set the perons's expiry to the maximum with

# passwd -x <username>

Thanks
Stephen
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
wesly_chenCommented:
By default,
useradd <username>
passwdd <username>
as root, the password of <username> won't expire unless you enforce on pam.d or /etc/login.defs.
0
 
traderhank1Author Commented:
I don't see anything relating to expiration in login.defs , I don't know anything about pam.d
everytime I create a new user I have to fire-up X and uncheck enable password expiration.
0
 
steveb3210Commented:
The "chage" command will change the expiration of a specific user.

/etc/login.defs defines the default max password age, PASS_MAX_DAYS

When you do adduser, the default password expiry is set to that value.  Change that value to be 99999 for the maximum lenght - I trust your user won't live to be 273years old.

useradd only takes the values in the form of a date, e.g

useradd -e 2299-01-01 bob

would add a user named bob who would expire on January 1st, 2229

I think you really just want to set PASS_MAX_DAYS and you'll be all set.  You might need to reset all the other users in your system if they haven't been all set not to expire..You can do that with

for m in `cat /etc/passwd|awk -F: {'print $1'}`;do chage -M 99999 $m;done

Best Regards,
Stephen
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now