- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Making a useradd script
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
07-15-2008 07:55 AM
07-15-2008 07:55 AM
My system is a 11.11 and I'm trying to make a script so giving a username it makes the useradd with a specified home.
Making this once may not be worth a script but I have 4 other machines with local autentication, and my next step is to trigger via ssh the changes on the main one.
I've seen I can use useradd.sam to pass a password but it seems to be taken as a preencripted MD5 one.
My script would do something like this :
PASSWORD = Encrypt (username)
useradd.sam -p PASSWORD username
(I want username = password)
I didn't find anyone who tried user creation with scripts but this is important for my workaround. (if there is any easier way tell please)
Excuse my english, thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2008 08:39 AM
07-15-2008 08:39 AM
Re: Making a useradd script
You might wish to go with a LDAP or NIS based authentication system to let one computer handle authentication on all.
Don't use useradd.sam
User useradd directly in your script, make sure the default user configuration is in /etc/skel so the user looks good.
Add customization for NFS and other oddities.
(I want username = password)
Bad idea, violates common sense and will be used against you on the next security audit.
Set a policy and have a password that expires in 7 days (Build that into your script).
Or Empty the password and use the passwd command to force new password at first login
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2008 11:18 AM
07-15-2008 11:18 AM
Re: Making a useradd script
Yes, this requires the encrypted password. The attached script will return the encrypted password suitable for useradd.sam -p.
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2008 11:22 AM
07-15-2008 11:22 AM
Re: Making a useradd script
#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);
}
You run it interactively to obtain the encrypted password, then you can use the result in useradd.sam
Bill Hassell, sysadmin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2008 12:28 PM
07-15-2008 12:28 PM
Re: Making a useradd script
Here's a simple Perl script to generate an encrypted password that you can use with your 'useradd':
# cat .pwgen
#!/usr/bin/perl -l
die "One arg expected\n" unless @ARGV;
print crypt(
$ARGV[0],
join( '',
( '.', '/', 0 .. 9, 'A' .. 'Z', 'a' .. 'z' )[ rand 64, rand 64 ] )
);
1;
...run as:
# ./pwgen plaintext
The script's output is your corresponding encrypted password.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2008 05:43 PM
07-15-2008 05:43 PM
Re: Making a useradd script
do
useradd -u ${uid} -g ${gid} -c "${gecos}" -d ${home} -m -s ${shell} ${user}
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2008 06:40 PM
07-15-2008 06:40 PM
SolutionTake a look at another possibility.
I wrote it for Unix support team who
needed to add around 500 Unix accounts
on AIX, Linux, Solaris and HP-UX servers
(without manual intervention):
http://www.circlingcycle.com.au/Unix-sources/add-batch-Unix-accounts.pl.txt
Cheers,
VK2COT
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-15-2008 11:24 PM
07-15-2008 11:24 PM
Re: Making a useradd script
May I say that this is not a critical machine, it's for only one aplication, and only LAN use, so I can't change the requirements (username = passwd) but hurts!
thanks one more time. I keep working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-16-2008 01:33 AM
07-16-2008 01:33 AM
Re: Making a useradd script
Thanks one more time.
Now I know exactly what I need.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2008 01:49 AM
07-17-2008 01:49 AM
Re: Making a useradd script
I'm having problems with useradd.sam parameters.
./useradd.sam -d /opt/oracle/tstusr -m
With useradd this would create the home dir in the specified folder, but with useradd.sam, it creates the user, writes the /home atribute correctly, but doesn't create it.
any ideas?
thks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2008 02:05 AM
07-17-2008 02:05 AM
Re: Making a useradd script
I'll do :
useradd -d $home user
usermod.sam -p $passwd user
as the script did...
so it creates the path
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-17-2008 04:27 AM
07-17-2008 04:27 AM
Re: Making a useradd script
As you conclude, please see:
http://forums12.itrc.hp.com/service/forums/helptips.do?#28
Regards!
...JRF...