- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Need to remove bug
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2007 10:16 AM
12-04-2007 10:16 AM
Need to remove bug
I was try to create one script to set the initial passswd for all users at one server in one go.
I created one file "newusers" put all the users in this file ,those need be set initial passwd as "hello123"
.
I also created one script "userpasswd.sh" Now I'm trying to run this script from my home directory. The script run normally but not implemented .
Here is some out put
SCRIPT
root@XXX $ cat userpasswd
#!/usr/bin/ksh
cd /home/xxx
for i in `cat newusers`;
do
(echo clear; sleep 2;echo "passwd $i";sleep 2;echo "p";sleep 2;echo "hello123";sleep 2;echo "hello123";sleep 2;echo exit)
done
root@xxx$./userpasswd
clear
passwd ABC123
p
hello123
hello123
exit
clear
passwd DEF456
p
hello123
hello123
exit
clear
(output truncated only show you for 2 users )
(change user names as ABC123 and DEF456)
Script runs well as above and after completing when I was trying to log in with the user id and new passwd "hello123" its not worked
Anyone can correct my script ?
- Tags:
- passwd
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2007 10:29 AM
12-04-2007 10:29 AM
Re: Need to remove bug
You are not going to be able to set a password interactively by attempting to supply input the the 'passwd' command.
You can created an encrypted password from a plaintext one using 'crypt' in a shell or (better) Perl script and replace the current encrypted password with a new one in the appropriate line (account) of either '/etc/passwd' or '/etc/shadow', however.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2007 10:30 AM
12-04-2007 10:30 AM
Re: Need to remove bug
echo "passwd $i" will just print out
passwd ABCD. Take out the echo's and then try the script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2007 10:33 AM
12-04-2007 10:33 AM
Re: Need to remove bug
It will be lot easier if you use expect.
Have a look at this thread for an example.
http://forums11.itrc.hp.com/service/forums/questionanswer.do?threadId=1148400&admit=109447626+1196792844104+28353475
http://hpux.cs.utah.edu/hppd/hpux/Tcl/expect-5.43/
Regards,
Robert-Jan
- Tags:
- expect
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2007 10:38 AM
12-04-2007 10:38 AM
Re: Need to remove bug
[nlxsms01:root:/]# useradd test
[nlxsms01:root:/]# passwd test
Changing password for test
Last successful password change for test: NEVER
Last unsuccessful password change for test: NEVER
Do you want (choose one letter only):
pronounceable passwords generated for you (g)
a string of letters generated (l) ?
to pick your passwords (p) ?
Enter choice here: p
New password:
Re-enter new password:
Passwd successfully changed
[nlxsms01:root:/]# cat /tcb/files/auth/t/test
test:u_name=test:u_id#121:\
:u_pwd=CdtaJC2yiZ6NY:\
:u_auditid#202:\
:u_auditflag#1:\
:u_succhg#1196792815:u_pwchanger=root:u_suclog#1196792800:u_lock@:\
:chkent:
[nlxsms01:root:/]#
step 2
set the passwd:
ad to the usercreation script:
password=CdtaJC2yiZ6NY
/usr/sam/lbin/usermod.sam -p ${password} ${user}
ore
/usr/sam/lbin/usermod.sam -p CdtaJC2yiZ6NY $user
- Tags:
- usermod.sam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2007 10:44 AM
12-04-2007 10:44 AM
Re: Need to remove bug
to set a passwd on hp you have to change the encripted key,
in the past I have used the script below, but the samline seems to be working also fine...
ofcause you need to whange the first 3 lines
PW_USER=username
PW=Xejkfwskfhskkjsd
SUDO=/???/???/sudo
PW_USER_CUT=`echo $PW_USER|cut -c 1`
echo "-----------`uname -n`---`date`--------------------------"
#Check if system is trusted and execute trusted code
$SUDO cp /tcb/files/auth/$PW_USER_CUT/$PW_USER /tcb/files/auth/$PW_USER_CUT/${PW_USER}.old
if [ $? -eq 0 ] ; then
echo "System is trusted --> Changing the /tcb/files/auth/ file"
$SUDO ksh -c "sed -e \"s/:u_pwd=.*:/:u_pwd=${PW}:/\" /tcb/files/auth/$PW_USER_CUT/${PW_USER}.old > /tcb/files/auth/$PW_USER_CUT/$PW_USER"
$SUDO /usr/lbin/modprpw -v $PW_USER
$SUDO /usr/lbin/modprpw -k $PW_USER
$SUDO authck -p
else
echo "System is not trusted --> Changing the /etc/passwd file"
#Execute code for non trusted systems
$SUDO cp /etc/passwd /etc/passwd.old
if [ $? -eq 0 ] ; then
$SUDO ksh -c "awk -F: '{ if(/^$PW_USER/) {sub(/:[^:]*:/, \":${PW}:\" ) ; print \$0 } else print \$0 }' \
/etc/passwd.old >/etc/passwd" && \
for i in /etc/passwd /etc/passwd.old;do
$SUDO chmod 444 $i
$SUDO chown root:sys $i
done
else
echo "ATTENTION: copy of /etc/passwd failed"
fi
fi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-04-2007 10:50 AM
12-04-2007 10:50 AM
Re: Need to remove bug
most distributions come w/ "autopasswd" that requires 2 args, the user to change, and the new, unencrypted password.