Operating System - HP-UX
1822430 Members
3239 Online
109642 Solutions
New Discussion юеВ

Adding users non-interactively?

 
dictum9
Super Advisor

Adding users non-interactively?


How do I add users non-interactively?

The password command doesn't seem to give that option?
7 REPLIES 7
James R. Ferguson
Acclaimed Contributor

Re: Adding users non-interactively?

Hi:

See the man pages for 'useradd':

http://docs.hp.com/en/B2355-60127/useradd.1M.html

Regards!

...JRF...

Steven E. Protter
Exalted Contributor

Re: Adding users non-interactively?

I would suggest a useradd script:

Snip
----
useradd(1M) useradd(1M)

NAME
useradd - add a new user login to the system

SYNOPSIS
useradd [-u uid [-o] ] [-g group] [-G group [, group...]] [-d dir]
[-s shell] [-c comment] [-m [-k skel_dir]] [-f inactive]
[-e expire] [-r update_homedir_ownership] login

useradd -D [-g group] [-b base_dir] [-f inactive] [-e expire]
[-r update_homedir_ownership]

DESCRIPTION
The useradd command creates a user login on the system by adding the
appropriate entry to the /etc/passwd file and any security files,
modifying the /etc/group file as necessary, creating a home directory,
and copying the appropriate default files into the home directory
depending on the command line options. The new login remains locked
until the passwd (see passwd(1)) command is invoked.

-----

Example

useradd schmo -G bagel


You can create a user template in /etc/skel that would be able to handle all customizations that your users require.

The passwd command is for password changes, and reports on user password status (passwd -sa)

A releated and possibly useful thread.
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=478688

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
dictum9
Super Advisor

Re: Adding users non-interactively?

I don't know why I said "passwd", I meant useradd of course. In the past I have scripted this with Expect/TCL but it was a long script to handle all the possibilities. And I *did* read the manpages on useradd, there is nothing in there which indicates this can be done easily, such as the password string passwd on the command line, as insecure as it is.
Mark Nieuwboer
Esteemed Contributor

Re: Adding users non-interactively?

Hi,

I don't know exactly what your asking.
First you asked how to add users to a system without using sam i gues. But the question is to give a password directly with useradd.
This is not possible you need to give to commands for this. 1 useradd, second passwd.
You can change some security settings with /usr/lbin/modprpw but that is not one of them.

p.s try to do something about your poor score.

I have assigned points to 20 of 135 responses to my questions.

it's nice to give some reward to the people who are helping you.

grtz. Mark
Sivakumar TS
Honored Contributor

Re: Adding users non-interactively?



Hi,

You can create the user non interactively using #useradd command,

bt after this you have to use #passwd to assign a password and activate the account.

With Regards,

Siva.
Nothing is Impossible !
Muthukumar_5
Honored Contributor

Re: Adding users non-interactively?

HP-Ux is not support an option to give string with passwd command as like linux. For automating user creation you have to use expert scripting.

You can create users and force the user to set password during first login with passwd utility but not assigning passwd with command itself.

--
Muthu
Easy to suggest when don't know about the problem!
Muthukumar_5
Honored Contributor

Re: Adding users non-interactively?

Without expect script, there is a possibility to achive with telnet + piping as said in,

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=981127

--
Muthu
Easy to suggest when don't know about the problem!