The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Interpreting the encrypted shadow password? keelba Linux 5 03-12-2008 06:13 PM
*LK* in /etc/shadow file vikashtulsiyan SUN Solaris 5 12-23-2007 08:50 PM
shadow file after a password reset progressdll UNIX for Dummies Questions & Answers 0 10-31-2007 02:18 AM
shadow file jbashir UNIX for Advanced & Expert Users 3 03-14-2006 12:22 AM
remove shadow password gizaa UNIX for Dummies Questions & Answers 2 08-03-2004 04:30 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 03-21-2006
Registered User
 

Join Date: Mar 2006
Posts: 3
Angry I want to append password in /etc/shadow file

Hi,
I want to append password into /etc/shadow file using a shell script.
My below script does add the users to both /etc/passwd and /etc/shadow but how can I add the hordcoded passwords to /etc/shadow file can some one help me ?


# To add the groups into /etc/group file

for a_user in nortel admin netmgr master operator ttbuser orbix oracle
do
/usr/sbin/useradd $a_user >> one
done
Reply With Quote
Forum Sponsor
  #2  
Old 03-21-2006
Registered User
 

Join Date: Mar 2006
Location: South Yorkshire, UK
Posts: 114
Passwords

The password in /etc/shadow is encrypted. To add/change a password, use the passwd command (see the man pages for options).

cheers
Reply With Quote
  #3  
Old 03-21-2006
Registered User
 

Join Date: Mar 2006
Posts: 3
Quote:
Originally Posted by thestevew
The password in /etc/shadow is encrypted. To add/change a password, use the passwd command (see the man pages for options).

cheers
Passwd command works in Interactive mode and I cant use expect also. I just want to hard code users and there password in one script.

# To add the users into /etc/password file
for a_user in nortel admin netmgr master operator ttbuser orbix oracle
do
/usr/sbin/useradd $a_user
done
This will add the users into /etc/password and /etc/shadow file. But how can I add passwords into shadow file withought using expect and in non Interactive mode ?
Reply With Quote
  #4  
Old 03-21-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,653
I'll tell you what I do, but it is a little risky. First I add the users to a "prototype" box. This is just some box where I start. I add the users, assign initial passwords, and I ask the user to sign on, change their passwords, and be sure that they like the shell, gcos info etc. I do not want to copy this around and then find that they csh or something. After the users accounts are all ready on the prototype box, I extract their lines from /etc/password and /etc/shadow. I use this to create a simple script that appends the lines to /etc/passwd and /etc/shadow. The script also makes the home directories, etc. I test this script on a test system. Once I am sure that I trust the script, I use an automated procedure to transfer to the boxes in question and run it. Like I said, this is a little risky. But I am careful and I am confident that I can correct any fumbles that occur.
Reply With Quote
  #5  
Old 03-21-2006
Registered User
 

Join Date: Mar 2006
Posts: 3
Quote:
Originally Posted by Perderabo
I'll tell you what I do, but it is a little risky. First I add the users to a "prototype" box. This is just some box where I start. I add the users, assign initial passwords, and I ask the user to sign on, change their passwords, and be sure that they like the shell, gcos info etc. I do not want to copy this around and then find that they csh or something. After the users accounts are all ready on the prototype box, I extract their lines from /etc/password and /etc/shadow. I use this to create a simple script that appends the lines to /etc/passwd and /etc/shadow. The script also makes the home directories, etc. I test this script on a test system. Once I am sure that I trust the script, I use an automated procedure to transfer to the boxes in question and run it. Like I said, this is a little risky. But I am careful and I am confident that I can correct any fumbles that occur.
Your view is challenging and good one but I cant use any of these system files too because of project requirment. I should use solaris commands like sed or cat which can append the hardcoded passwords into /etc/shadow file.
If you can write one command (sed or any one else) then it will be good help for me.
Thanx a lot
Reply With Quote
  #6  
Old 03-21-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,653
Code:
#! /usr/bin/ksh
cat >> /etc/passwd << \EOF
joeblow:x:1158:20:Joseph Q Blow:/home/joeblow:/bin/ksh
tomjones:x:1159:20:Thomas Jones:/home/tomjones:/bin/ksh
EOF
cat >> /etc/shadow << \EOF
joeblow:xxxxyyyyzzzz1:13220::::::
tomjones:xxxxyyyyzzzz1:13220::::::
EOF
exit 0
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 03:46 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0