passwd in shell script | Unix Linux Forums | Shell Programming and Scripting

  Go Back    


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

passwd in shell script

Shell Programming and Scripting


Tags
expect

Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 09-28-2006
corny corny is offline
Registered User
 
Join Date: Aug 2006
Last Activity: 3 October 2006, 1:55 AM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
passwd in shell script

Is there a way to change user password using passwd command in shell script?
I don't want to use expect.


Please help
Sponsored Links
    #2  
Old 09-28-2006
hitmansilentass hitmansilentass is offline
Registered User
 
Join Date: Sep 2006
Last Activity: 28 May 2014, 8:23 PM EDT
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
use the command passwd, it will ask for old password and then the new password twice
Sponsored Links
    #3  
Old 09-28-2006
corny corny is offline
Registered User
 
Join Date: Aug 2006
Last Activity: 3 October 2006, 1:55 AM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
I want to use it in a script without my interaction. I want to provide new password in a script a than run passwd to change user password.

Problem of using passwd in shell script is that passwd requires user interaction to change password and script stops. My question was is there a way to use passwd without interaction or is there other way to change password using shell script
    #4  
Old 09-28-2006
thestevew thestevew is offline
Registered User
 
Join Date: Mar 2006
Last Activity: 11 July 2008, 4:53 AM EDT
Location: South Yorkshire, UK
Posts: 114
Thanks: 0
Thanked 1 Time in 1 Post
To do what you want you would need to embed your password in a script in plain text - not good for security! Do you really want to do this?
Sponsored Links
    #5  
Old 09-28-2006
corny corny is offline
Registered User
 
Join Date: Aug 2006
Last Activity: 3 October 2006, 1:55 AM EDT
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Yes I want
Sponsored Links
    #6  
Old 09-28-2006
nathan nathan is offline VIP Member  
Supporter
 
Join Date: Jul 2006
Last Activity: 15 February 2012, 11:03 AM EST
Posts: 168
Thanks: 0
Thanked 0 Times in 0 Posts
From my man page on passwd... . Yours might not accept input from a script, depending on the system.

Code:
PASSWD(1)                       User utilities                       PASSWD(1)

NAME
       passwd - update a userís authentication tokens(s)
...
       --stdin
              This  option  is  used  to indicate that passwd should read the new password
              from standard input, which can be a pipe.

Sponsored Links
    #7  
Old 09-29-2006
mdhmi mdhmi is offline
Registered User
 
Join Date: Sep 2006
Last Activity: 3 October 2006, 3:44 AM EDT
Location: Detroit, Michigan
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by thestevew
To do what you want you would need to embed your password in a script in plain text - not good for security!
You could embed only the encrypted portion of the password and use sed to update /etc/shadow.

nathan - the "--stdin" option is not universial.
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help required to write shell script to change passwd gr8_usk Shell Programming and Scripting 0 06-17-2011 08:51 AM
Root shell in /etc/passwd is corrupted aixlover Red Hat 7 03-08-2010 02:52 PM
Change /etc/passwd shell to telnet with parameters tux0084 Shell Programming and Scripting 2 11-04-2009 10:21 PM
Why passwd isnt working in shell scripts? Deepa Shell Programming and Scripting 1 01-31-2003 09:46 AM
How to "su" along with passwd within a shell script? unique UNIX for Advanced & Expert Users 2 09-19-2001 08:09 AM



All times are GMT -4. The time now is 09:48 AM.