Portal Home > Knowledgebase > Articles Database > shell script ADD ftp user


shell script ADD ftp user




Posted by hostcheetah, 04-28-2011, 06:37 AM
Can anyone here help me with a bash script to add ftp user to a centos server with no control panel

Posted by bdwarr6, 04-28-2011, 07:08 AM
You can save the following to a file and add a user like this, ./filename.sh domain.com or whatever #!/bin/bash echo "Add New User to Backup System"; useradd -g backup -d /home/$1/ -c "`echo $1 | sed 's/\./\-/g'`" `echo $1 | sed 's/\./\-/g'`; mkdir /home/$1/ chown -R `echo $1 | sed 's/\./\-/g'`:504 /home/$1/ echo `echo $1 | sed 's/\./\-/g'` >> /etc/vsftpd/chroot_list sed -i "s/:\/home\/$1\/:\/bin\/bash/:\/home\/$1\/:\/bin\/ftp/g" /etc/passwd #---------------------------------------------------------------------------# #----------------Password Generator-----------------------------------------# #---------------------------------------------------------------------------# # Sets the maximum size of the password the script will generate MAXSIZE=32 # Holds valid password characters. I choose alpha-numeric + the shift-number key board keys # I put escape chars on all the non alpha-numeric characters just for precaution array1=( w e r t y u p a s d f h j k z x c v b m Q W E R T Y U P A D F H J K L Z X C V B N M 2 3 4 7 8 ! @ % \# \* \= \- \+ \? ) # Used in conjunction with modulus to keep random numbers in range of the array size MODNUM=${#array1[*]} # Keeps track of the number characters in the password we have generated pwd_len=0 while [ $pwd_len -lt $MAXSIZE ] do index=$(($RANDOM%$MODNUM)) password="${password}${array1[$index]}" ((pwd_len++)) done #Set New Root Password echo -e "$password\n$password" | (passwd --stdin `echo $1 | sed 's/\./\-/g'`) echo "FTP Host: "`ifconfig | grep 'inet addr' | sed -n '1p' | awk -F ":" {'print $2}' | awk -F " " '{print $1}'`; echo "FTP Port: 21"; echo "FTP Path: /home/"$1"/"; echo "Username: "`echo $1 | sed 's/\./\-/g'`; echo "Password: "$password;

Posted by hostcheetah, 04-28-2011, 07:21 AM
thank you do u have a script to add Email

Posted by Mariejane, 04-28-2011, 09:00 AM
This is great, thanks a lot bdwarr6!



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
VPS with CPV Lab (Views: 8501)
opinion on my new site (Views: 675)


Language: