View Single Post
  #1   (View Single Post)  
Old 18th January 2010
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,128
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