Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2011
    Location
    Savannah!
    Posts
    58

    shell script ADD ftp user

    Can anyone here help me with a bash script to add ftp user to a centos server with no control panel

  2. #2
    Join Date
    Oct 2004
    Location
    root
    Posts
    870
    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;
    Nick Rose | BudgetVM
    BudgetVM Xen VPS with Solus
    Asia and Europe Hosting Specialists
    LA to Asia <150MS | Amsterdam within Europe <60MS

  3. #3
    Join Date
    Apr 2011
    Location
    Savannah!
    Posts
    58
    thank you

    do u have a script to add Email

  4. #4
    Join Date
    Apr 2011
    Location
    Germany
    Posts
    7
    This is great, thanks a lot bdwarr6!

Similar Threads

  1. Need Shell script to add prefix to multiple files' name.
    By viettechorg in forum Programming Discussion
    Replies: 7
    Last Post: 03-26-2007, 12:56 AM
  2. automated ftp upload via shell script
    By chamelion in forum Hosting Security and Technology
    Replies: 3
    Last Post: 04-09-2006, 06:43 PM
  3. how to add a new ftp user in windows 2003
    By lover in forum Hosting Security and Technology
    Replies: 5
    Last Post: 11-07-2004, 02:52 PM
  4. FTP Shell Script Help
    By AlpineZone in forum Hosting Security and Technology
    Replies: 7
    Last Post: 04-09-2004, 05:56 AM
  5. FTP shell script
    By WoodShedd in forum Hosting Security and Technology
    Replies: 3
    Last Post: 06-28-2002, 10:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •