addsshuser
#!/bin/sh
# addsshuser - add user to the ssh gateway
#
# addsshuser [username]
#
# generates random password, creates an account and prints
# the account information including a link to the manual
# to hand over to the user
#
# depends on the following executables: pwgen openssl lp useradd
if [ $# -lt 1 ]
then
echo `basename $0` requires a username
exit 1
fi
USER=$1
PWGEN_BIN=pwgen
PASSWORD=`$PWGEN_BIN -cn -1`
PW_HASH=`openssl passwd -1 ${PASSWORD}`
# print the account information
cat <<eof | lp
manual: http://intranet/remoteaccesshowto.html
username: ${USER}
password: ${PASSWORD}
EOF
# create the user account
useradd -M -p ${PW_HASH} ${USER}