ftp.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #!/bin/sh
  2. echo '\033[35m
  3. ______ _______ _____
  4. | ____|__ __| __ \
  5. | |__ | | | |__) |
  6. | __| | | | ___/
  7. | | | | | |
  8. |_| |_| |_|
  9. \033[0m'
  10. if [ "$EUID" -ne 0 ]
  11. then echo "Please run as root"
  12. exit
  13. fi
  14. # get the current position
  15. _cwd="$(pwd)"
  16. # check for assets forlder
  17. _assets="$_cwd/assets"
  18. if [ ! -d "$_assets" ]; then
  19. _assets="$_cwd/../assets"
  20. if [ ! -d "$_assets" ]; then
  21. echo "!! can't find assets directory !!"
  22. exit
  23. fi
  24. fi
  25. echo "installing proftpd"
  26. apt-get --yes --force-yes install proftpd
  27. while [ "$_server_name" = "" ]
  28. do
  29. read -p "enter a server name ? " _server_name
  30. if [ "$_server_name" != "" ]; then
  31. read -p "is server name $_server_name correcte [y|n] " validated
  32. if [ "$validated" = "y" ]; then
  33. break
  34. else
  35. _server_name=""
  36. fi
  37. fi
  38. done
  39. echo "Configuring proftpd"
  40. cp "$_assets"/proftpd.conf /etc/proftpd/conf.d/"$_server_name".conf
  41. sed -i -r "s/example/$_server_name/g" /etc/proftpd/conf.d/"$_server_name".conf
  42. ufw allow ftp
  43. addgroup ftpuser
  44. systemctl enable proftpd
  45. systemctl restart proftpd
  46. echo "ftp installtion done"
  47. echo "to permit to a user to connect through ftp, add him to the ftpuser group by running : usermod -a -G ftpuser USERNAME"
  48. echo "FTP users are jailed on their home by default"
  49. # TODO : allow ssh/ftp connection only from given ips