- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Batch job to set password
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
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
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
тАО10-20-2006 10:12 AM
тАО10-20-2006 10:12 AM
Batch job to set password
I would like to run a script and set the users password to "something" and then force user to change it at first log on.
Here is what I have wrote so far.
for USER in `cat cifsuser1`
do
useradd -g users -m $USER
passwd -d $USER
"I neeed help here"
passwd -f $USER
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2006 10:47 AM
тАО10-20-2006 10:47 AM
Re: Batch job to set password
You can use /usr/sam/lbin/uusermod.sam -F -P user1 to assign the password for user1. But ... (sorry, but) you have to use encrypted password (cW7789FCXD). You need to run crypt of perl crypt to encrypt the passwords.
Yang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2006 01:26 PM
тАО10-20-2006 01:26 PM
Re: Batch job to set password
#include
#include
/* 1st param is the desired password */
/* A random seed (2 chars) will be */
/* automatically chosen. */
/* For good passwords: */
/* Use random chars, mixed apha- */
/* numerics and MiXeD CaSe for */
/* better protection. */
main(argc, argv)
int argc;
char *argv[];
{
char salt[3];
char *EncryptedPasswd;
int CheckRand;
int Fixup;
int SeedChar;
printf("\nUsage: pw
/* Generate a random starting point for seed charcaters */
srand(time(NULL));
for ( SeedChar = 0; SeedChar <= 1; SeedChar++) {
CheckRand = 46 + rand() % 76; /* random number from 46 to 122 */
Fixup = 7 + rand() % 13; /* random number from 7 to 20 */
salt[SeedChar] = toascii(((CheckRand >= 58 && CheckRand <= 64) ||
(CheckRand >= 91 && CheckRand <= 96) ? CheckRand + Fixup : CheckRand));
}
EncryptedPasswd=crypt(argv[1], salt);
printf("\nRequested pw= %s, Automatic Seed= %s, encrypted pw= %s\n",
argv[1], salt, EncryptedPasswd);
}
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-20-2006 01:52 PM
тАО10-20-2006 01:52 PM
Re: Batch job to set password
The trick is to use /usr/sam/lbin/useradd.sam. That program accepts a -p ${pwd} option; however, as mentioned, the password has to be encrypted. Here's how I would do it.
1. Generate a data file for your users in the format:
${user1}|${gecos}|${primary_group}|${alt_groups}
${user2}|${gecos}|${primary_group}|${alt_groups}
${user3}|${gecos}|${primary_group}|${alt_groups}
2. Add a temporary user, set the password you want, then obtain the encrypted password from /etc/shadow, or /tcb/files/auth/${l}/${user}.
3. ID the beginning uid - some stretch that you have 400 uids available.
4. Write the following inline script
pwd=${enc_pwd}
uid=${uid}
cat users | while IFS=| read user gecos pgrp groups
do
printf "%-8s %-5d %s\n" ${user} ${uid} "${gecos}"
/usr/sam/lbin/useradd.sam -p ${pwd} -u ${uid} -g ${pgrp} -G ${groups} -d /home/${user} -s /bin/ksh ${user}
mkdir -m 755 -p /home/${user}
cp /etc/skel/.[A-z]* /home/${user}
chown -R ${user}:${pgrp} /home/${user}
uid=$((uid+1))
/bin/passwd -f ${user}
done
That should do the trick for you.
Doug
------
Senior UNIX Admin
O'Leary Computers Inc
linkedin: http://www.linkedin.com/dkoleary
Resume: http://www.olearycomputers.com/resume.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-23-2006 08:37 AM
тАО10-23-2006 08:37 AM