LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Security (https://www.linuxquestions.org/questions/linux-security-4/)
-   -   Change password with out any prompt, How ? (https://www.linuxquestions.org/questions/linux-security-4/change-password-with-out-any-prompt-how-4175449253/)

redhat70 02-08-2013 10:18 PM

Change password with out any prompt, How ?
 
Hi,

I want to create the users and set the passwords to 'eW4hNXNIc' for all new users.I don't want any prompts or confirmation when creating the users.

Is there a way to achieve this in REDHAT LINUX ? Can some one help?


regards,
aparna.

druuna 02-09-2013 01:30 AM

Quote:

Originally Posted by redhat70 (Post 4887428)
I want to create the users and set the passwords to 'eW4hNXNIc' for all new users.I don't want any prompts or confirmation when creating the users.

Is there a way to achieve this in REDHAT LINUX ? Can some one help?

You can do the following when using RedHat:
Code:

# create user the normal way:
$ /usr/sbin/useradd -c "Comment goes here" -m -d /home/username -s /bin/bash -u 500 -g 500 username

# set password:
/bin/echo "very_secret" | passwd --stdin username

To my knowledge the password --stdin username construct is only supported in RedHat and RedHat based distro's.

TB0ne 02-09-2013 09:05 AM

Quote:

Originally Posted by redhat70 (Post 4887428)
Hi,
I want to create the users and set the passwords to 'eW4hNXNIc' for all new users.I don't want any prompts or confirmation when creating the users.
Is there a way to achieve this in REDHAT LINUX ? Can some one help?

Along the same lines of your very first post here last year:
http://www.linuxquestions.org/questi...-boxes-947742/

You've been here a year now, and you seem to only want us to look things up for you.

jsaravana87 02-09-2013 02:23 PM

The below command works fine in my Dedian & Ubuntu based Operating system

echo "username:password" | chpasswd

Skaperen 02-10-2013 02:02 PM

Quote:

Originally Posted by arun5002 (Post 4887797)
The below command works fine in my Dedian & Ubuntu based Operating system

echo "username:password" | chpasswd

I've seen cases where that kind of thing fails due to stdin not being a tty (picky program reading for the password). In such cases I've usually found that the "script" program (and a delay in sending in the password) works. The "expect" program (or "pexpect" with a Python script) can also help.


All times are GMT -5. The time now is 05:48 PM.