All pastes #57917 Raw Edit

Mine

public text v1 · immutable
#57917 ·published 2006-05-22 06:10 UTC
rendered paste body
  #!/bin/bash
  GROUP=100
  HOME=/home
  SKEL=/etc/skel
#  INACTIVE=0
 # EXPIRE=60
  SHELL=/bin/bash

  #  passwd defaults

  PASSMIN=0
  PASSWARN=14
  #
  #  check for root access
  #
  WHOAMI=`/usr/bin/whoami`
  if [ $WHOAMI != "root" ]; then
          echo "You must be root to add news users!"
          exit 1
  fi
  #
  #  info
  #
  echo ""
  echo -n "Username: "
  read USERNAME
  echo -n "Full name: "
  read FULLNAME
  #
  echo "Adding user: $USERNAME."
  #
  #
  /usr/sbin/useradd -c"$FULLNAME" -d$HOME/$USERNAME \
           -g$GROUP -m -k$SKEL -s$SHELL $USERNAME
  #
  #  Set password defaults
  #
  /usr/bin/passwd -n $PASSMIN -w $PASSWARN $USERNAME >/dev/null 2>&1
#
  #second time
  #
  /usr/bin/passwd $USERNAME
  #
  #  confirm creation...
  #
  echo ""
  echo "Entry from /etc/passwd:"
  echo -n "   "
  grep "$USERNAME:" /etc/passwd
  echo "Entry from /etc/shadow:"
  echo -n "   "
  grep "$USERNAME:" /etc/shadow
  echo "Summary output of the passwd command:"
  echo -n "   "
  passwd -S $USERNAME
  echo ""
  echo "AllowUsers $USERNAME" >> /etc/ssh/sshd_config
  service sshd restart