Advertisement
efxtv

How to setup and configure an FTP server in Linux?

Sep 2nd, 2023 (edited)
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.15 KB | Cybersecurity | 0 0
  1. Title: Setup FTP server in Linux file sharing.
  2.  
  3. # ======Setup FTP in Linux======
  4. # UPDATE and install ftp
  5. sudo apt update;sudo apt upgrade
  6. sudo apt install vsftpd
  7. sudo service vsftpd status
  8.  
  9. # Go to the end of the file and add two lines
  10. sudo nano /etc/vsftpd.conf
  11. user_sub_token=$USER
  12. local_root=/home/$USER/ftp
  13. pasv_min_port=10000
  14. pasv_max_port=10100
  15. userlist_enable=NO
  16. userlist_file=/etc/vsftpd.userlist
  17. userlist_deny=NO
  18. allow_anon_ssl=NO
  19. force_local_data_ssl=NO
  20. force_local_logins_ssl=NO
  21.  
  22.  
  23. # Configure the firewall
  24. sudo ufw allow from any to any port 20,21,10000:10100 proto tcp
  25.  
  26. # Add user will have access to FTP
  27. sudo adduser efx
  28.  
  29. # Create a folder in home (ftp)
  30. sudo mkdir /home/efx/ftp
  31.  
  32. # Change owner to public
  33. sudo chown nobody:nogroup /home/efx/ftp
  34.  
  35. # Remove the right permission
  36. sudo chmod a-w /home/efx/ftp
  37.  
  38. # Create an upload directory
  39. sudo mkdir /home/efx/ftp/upload
  40.  
  41. # Change owner to non-user
  42. sudo chown demo:demo /home/efx/ftp/upload/
  43.  
  44. # Create a demo file in the upload directory
  45. echo hi >/home/efx/ftp/upload/saved.txt
  46.  
  47. # Add the user to FTP to log in and access the FTP server
  48. $ echo "demo" |sudo tee -a /etc/vsftpd.userlist
  49.  
  50. # Restart the FTP server to apply the changes
  51. $ sudo systemctl restart vsftpd
  52.  
  53. # Create a certificate to secure the FTP connection
  54. sudo openssl req -x509 -nodes -days 3650 -newkey rsa:2048 -keyout /etc/ssl/private/vsftpd.pem -out /etc/ssl/private/vsftpd.pem
  55.  
  56. # Edit ftp config file once again and change the certificate location to
  57. sudo nano /etc/vsftpd.conf
  58. rsa_cert_file=/etc/ssl/private/vsftpd.pem
  59. rsa_private_key_file=/etc/ssl/private/vsftpd.pem
  60. ssl_enable=YES
  61.  
  62. # Restart server
  63. sudo systemctl restart vsftpd
  64.  
  65. # ======FTP commands to use in Linux======
  66. # Connect ftp
  67. ftp 192.168.1.5
  68. enter user
  69. enter password
  70.  
  71. # Download file (DBs, zip)
  72. get <filename>
  73.  
  74. # Upload file (shell)
  75. put <filename>
  76.  
  77. # Exit
  78. bye
  79.  
  80. # more ftp client commands
  81. cd - change remote working directory
  82. lcd - change local working directory
  83. get - recieve file
  84. mget - get multiple files
  85. passive - enter passive transfer mode
  86. ls - list contents of remote directory
  87.  
  88. Telegram Post: https://t.me/efxtv/2723
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement