Hi All,
I used to create users for my local hosting with adduser. also I need to add some directories in home dir and sql Databases. I decided to create script for automation.
The first problem that I can not login by new user. Even when I add user to wheel group and change password with passwd command.
some info...
Help please.
I used to create users for my local hosting with adduser. also I need to add some directories in home dir and sql Databases. I decided to create script for automation.
Code:
#!/bin/sh
#Creates new project
#ver. 0.1 from 26.12.2009
### user ###
echo "Enter projectname to create:"
read PROJECT
if [ -z $PROJECT ]; then
exit
fi
USERPASS=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`
SQLPASS=`< /dev/urandom tr -dc A-Za-z0-9 | head -c8`
pw groupadd $PROJECT
pw user add $PROJECT -d /home/$PROJECT -m -s /bin/sh -G $PROJECT
echo '$USERPASS' |pw usermod $PROJECT -h 0
### directories ###
mkdir /home/$PROJECT/htdocs
mkdir /home/$PROJECT/logs
chmod -R 755 /home/$PROJECT
chown -R $PROJECT /home/$PROJECT
### MySQL ###
mysql -t <<STOP
CREATE DATABASE $PROJECT default character set utf8 collate utf8_general_ci;
CREATE USER '$PROJECT'@'localhost' Identified by '$SQLPASS';
GRANT ALL ON $PROJECT.* TO '$PROJECT'@'localhost';
\q
STOP
echo "User name: $PROJECT"
echo "User password: $USERPASS"
echo "MySQL password: $SQLPASS"
The first problem that I can not login by new user. Even when I add user to wheel group and change password with passwd command.
some info...
Code:
h01# ./addproject.sh
Enter projectname to create:
test12
User name: test12
User password: LNfIt1SW
MySQL password: cNDgEZwv
h01# cat /etc/passwd | grep test12
test12:*:1015:1015:User &:/home/test12:/bin/sh
h01# cat /etc/group | grep test12
test12:*:1015:test12
h01# cat /var/log/auth.log |grep test12
Dec 26 18:58:11 h01 sshd[46756]: error: PAM: authentication error for test12 from x.x.x.74
h01#