LinuxQuestions.org
Register a domain and help support LQ
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 03-02-2005, 09:03 PM   #1
Arodef
Member
 
Registered: Apr 2004
Distribution: Centos, Fedora
Posts: 125

Rep: Reputation: 17
Question How to create script to change a user's password? passwd expects input from keyboard.


I need to create a script which changes the password for a user:

passwd joeblow

The problem is passwd now expects input from the keyboard rather than the script file. I need the script to be non-interactive so how would I script this so you would not have to manually enter the password at the prompt? BTW, it's okay for the password to be viewable in the file, encryption is not necessary for my usage. Thanks for any help!

Last edited by Arodef; 03-02-2005 at 09:27 PM.
 
Old 03-02-2005, 10:40 PM   #2
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
You could try calling a short expect script. Here is an article about it from linux-magazine: http://www.linux-mag.com/2001-01/guru_02.html

They have an example where they 'spawn' a chsh command, and the expect script responds with the new shell.

I don't know why a here document doesn't work:
passwd <<+++
oldpasswd
newpasswd
newpasswd
+++

I suspect that this may be something not allowed by pam_passwd.so
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Howto change system password policies (passwd length, complexity) tisource Linux - Security 3 09-06-2005 12:01 AM
which linux c function can change user's passwd henryluo Programming 1 07-15-2005 10:16 PM
Create custom user's directory with simple script dtournas Programming 2 09-09-2004 05:00 AM
need a script that can change the passwd bahadur Linux - Security 1 07-09-2004 05:07 AM
Bash script to edit passwd without Root password? NetFlash Linux - Newbie 2 11-29-2003 04:22 PM


All times are GMT -5. The time now is 01:06 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration