Create FTP User in Linux

Hello Everyone, Today we will learn How to create FTP user in Linux/EC2 server. We will use this ftp user to connect our Linux server from our local machine via Filezilla or other FTP clients.

So, First connect the Linux Server:

  • Install FTP Server(vsftpd)

For Ubuntu: ``` sudo apt-get install vsftpd ``` For Centos or RHEL: ``` sudo yum install vsftpd ```

  • Open Port on security group of your instance

add Custom TCP Rule **20-21** and Custom TCP Rule **1024-1048**.

  • Update the vsftpd.conf file
1sudo vim /etc/vsftpd.conf
  • Disable anonymous ftp access by changing the anonymous_enable=YES to anonymous_enable=NO

  • Add the below line in vsftpd.conf to allow chroot writable (optional):

1allow_writeable_chroot=YES
  • Restrict the FTP user to their home directory, simply un-comment the following line:
1chroot_local_user=YES
  • Add the below lines to the bottom of the vsftpd.conf file for passive setting:
1pasv_enable=YES
2pasv_min_port=1024
3pasv_max_port=1048
  • Restart FTP Server
1sudo service vsftpd restart
  • Now, Create FTP User
1sudo adduser ftpuser
2sudo passwd ftpuser
  • Change user’s home directory to your code Directory:
1sudo usermod -d /var/www/html/ ftpuser
  • Lastly, Change folder and file owner to ftpuser:
1sudo chown -R ftpuser:root /var/www/html/

Now Test the configuration by connecting the server via Filezilla client.

I :heart: Linux! :smile: Enjoy