Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ $(id -u) -eq 0 ]; then
- read -p "Friend username:" friend
- read -p "Friend email address:" friendemail
- read -p "Create VPN account for user : (yes/no)" yesno
- RPASS=$(makepasswd --char=6)
- egrep "^$friend" /etc/passwd >/dev/null
- if [ $? -eq 0 ]; then
- echo "$friend exists!"
- exit 1
- fi
- echo 'Adding user '$friend
- useradd -d /home/$friend -m -g friends -p -N $friend
- echo
- echo 'Setting random 6 letter password :'$RPASS
- echo $friend:$RPASS | chpasswd
- echo
- echo 'Applying 0750 to users home dir'
- chmod 0750 /home/$friend
- echo 'servername : bomber.dyndns.org' > message.txt
- echo 'port : 666' >> message.txt
- echo 'username : '$friend >> message.txt
- echo 'password : '$RPASS >> message.txt
- if [ $yesno = "yes" ]; then
- echo 'Adding user to VPN group'
- echo '$friend pptpd $RPASS *' >> /etc/ppp/chap-secrets
- fi
- echo -e '\n\n' >> message.txt
- echo -e '\n\n Remember that ALL access is monitored and logged.\n Place nicely :)' >> message.txt
- echo -e '\n\nBomber' >> message.txt
- echo 'Sending friend Account Creation Email to '$friendemail''
- sudo /usr/bin/mail -s 'bomber.dyndns.org | Account Created : '$friend $friendemail < message.txt
- rm message.txt
- echo
- echo
- echo 'Output of passwd & group files'
- cat /etc/passwd | grep $friend
- cat /etc/shadow | grep $friend
- cat /etc/group | grep friends
- echo 'Done with account creation...'
- else
- echo "Only root may add a user to the system"
- exit 2
- fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement