DaemonForums  

Go Back   DaemonForums > Miscellaneous > Guides

Guides All Guides and HOWTO's.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   (View Single Post)  
Old 18th January 2010
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 3,146
Thanked 182 Times in 149 Posts
Default OpenBSD: create user sh script

A couple of years ago I got tired of the interactive adduser(8) to create the the couple of user accounts, which I always use on OpenBSD.
The following, part of an install.site script, now automatically takes care of this.

Code:
#!/bin/sh

# ----------------------------------------------------
echo ADDING USERS

DEBUG=''
#DEBUG=echo 

#---------------------------
create_user() {
   local NAME PASSWORD UID
   NAME="$1"
   UID="$2"
   PASSWORD="$3"
   echo Creating user: ${NAME} 
   $DEBUG useradd \
        -m \
        -g ${NAME} \
        -G wheel,operator \
        -k /etc/skel \
        -d /home/${NAME} \
        -s /bin/ksh \
        -L staff \
        -p ${PASSWORD} \
        -u ${UID} \
        -g =uid \
         ${NAME} 
}

# password created with : $ echo MySecretPassword | encrypt -b8
# or                    : $ encrypt -b8 -p

create_user j65nko 1001 '$2a$08$vY3HJJAJhzAZ6yTbVxK5U.71cGBwDB6B4J/bwHmUNaa.laozj1yai' 
create_user robert 1002 '$2a$08$AU69JhvTJf1/KxFBl/7ZM.8pg.SN.Z1Hx8uh1uRE2j1oWht4XqjOK'
create_user john   1003 '$2a$08$s8aW6AbI1Z8D5o0SVKODA.JySV70MuQYZm9oSGua0MLz0V7Qw9eDe'
create_user snap   1004 '$2a$08$YyNR1QBLxsEupg0MZqhWtuNbjC4hr0fiZ5pN6dwxePmUi4xVRCFNi'
Study useradd(8) to understand the options. Consult encrypt(8) for info about encrypting the passwords.
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
 

Thread Tools
Display Modes

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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
HOWTO: mounting an USB device as normal non-root user in OpenBSD J65nko Guides 4 24th December 2008 01:43 AM
How to Run K3B with normal user openBSD 4.4 mfaridi OpenBSD General 6 12th November 2008 10:25 PM
Create a script to rmove oldest files disco Programming 5 14th July 2008 09:25 PM
Tried to create new partition using sysinstall but change is not permanent disappearedng FreeBSD General 7 6th July 2008 10:00 PM
Customizeable FTP auto-fetch script (OpenBSD snapshot download as example) J65nko Guides 2 1st June 2008 03:29 AM


All times are GMT. The time now is 01:44 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick