The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages 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 09:13 PM
*LK* in /etc/shadow file vikashtulsiyan SUN Solaris 5 12-23-2007 11:50 PM
shadow file after a password reset progressdll UNIX for Dummies Questions & Answers 0 10-31-2007 05:18 AM
shadow file jbashir UNIX for Advanced & Expert Users 3 03-14-2006 03:22 AM
remove shadow password gizaa UNIX for Dummies Questions & Answers 2 08-03-2004 07:30 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 03-21-2006
modgil modgil is offline
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
  #2 (permalink)  
Old 03-21-2006
thestevew thestevew is offline
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
  #3 (permalink)  
Old 03-21-2006
modgil modgil is offline
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 ?
  #4 (permalink)  
Old 03-21-2006
Perderabo's Avatar
Perderabo Perderabo is online now Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,100
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.
  #5 (permalink)  
Old 03-21-2006
modgil modgil is offline
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
  #6 (permalink)  
Old 03-22-2006
Perderabo's Avatar
Perderabo Perderabo is online now Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,100
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
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 10:26 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0