SHARE
TWEET

Untitled

a guest Dec 23rd, 2017 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  #!bin/bash
  2. #==============================
  3. #Owner: Adam Miller.
  4. #Creator: Adam Miller.
  5. #Function: To automatically add users to an SFTP server using information stored on a MySQL server.
  6. #Date: 26th of September, 2011.
  7. #==============================
  8.  
  9. n=1;
  10.  
  11. end=51;
  12.  
  13. while [ $n != $end ]
  14. do
  15.  
  16. echo "SELECT username FROM backup_clients WHERE id = '$n';" | mysql --disable-column-names -pXXXXXX clients
  17.  
  18. username=`echo "SELECT username FROM backup_clients WHERE id = '$n';" | mysql --disable-column-names -pXXXXXX clients`
  19.  
  20. echo "SELECT password FROM backup_clients WHERE id = '$n';" | mysql --disable-column-names -pXXXXXX clients
  21.  
  22. password=`echo "SELECT password FROM backup_clients WHERE id = '$n';" | mysql --disable-column-names -pXXXXXX clients`
  23.  
  24. pw=$(perl -e 'print crypt($ARGV[0], "password")' $password)
  25.  
  26. mkdir /home/$username
  27.  
  28. useradd -d /home/"$username" -p $pw "$username"
  29.  
  30. adduser $username sftponly
  31.  
  32. chown root.root /home/"$username"
  33.  
  34. mkdir /home/"$username"/backup
  35.  
  36. chmod a+w /home/"$username"/backup
  37.  
  38. setquota -u $username 0 20971520 0 0 /home/
  39.  
  40. (( n= $n + 1 ))
  41.  
  42. done
  43.  
  44. DATE=`date`;
  45.  
  46. echo "log completed.            -       $DATE" >> addclient.logs.text
  47. echo " " >> addclient.logs.text
  48.  
  49.  
  50. exit 0
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top