How to setup ftp server in ubuntu server

 To enable an FTP server on an Ubuntu server, you can use the `vsftpd` package, which is a popular and secure FTP server for Unix-like systems. Here's a step-by-step guide to install and configure `vsftpd` on Ubuntu:


### Step 1: Update your package list

First, ensure your package list is up-to-date by running:

```bash

sudo apt update

```


### Step 2: Install `vsftpd`

Install the `vsftpd` package using the following command:

```bash

sudo apt install vsftpd

```


### Step 3: Backup the default configuration file

Before making changes, it's a good idea to back up the original configuration file:

```bash

sudo cp /etc/vsftpd.conf /etc/vsftpd.conf.bak

```


### Step 4: Configure `vsftpd`

Open the configuration file using a text editor:

```bash

sudo nano /etc/vsftpd.conf

```


Make the following changes to the configuration file:


1. Uncomment the following lines by removing the `#` at the beginning:

    ```plaintext

    write_enable=YES

    local_umask=022

    chroot_local_user=YES

    ```


2. Add or modify the following lines to enable passive mode and set the user list:

    ```plaintext

    pasv_enable=YES

    pasv_min_port=10000

    pasv_max_port=10100

    userlist_enable=YES

    userlist_file=/etc/vsftpd.userlist

    userlist_deny=NO

    ```


### Step 5: Create the user list file

Create the `/etc/vsftpd.userlist` file and add the users that you want to allow FTP access to. For example:

```bash

sudo nano /etc/vsftpd.userlist

```

Add the username of each allowed user on a new line. For example:

```plaintext

user1

user2

```


### Step 6: Restart the `vsftpd` service

After making the configuration changes, restart the `vsftpd` service to apply them:

```bash

sudo systemctl restart vsftpd

```


### Step 7: Adjust the firewall

If you are using a firewall (like `ufw`), allow FTP traffic through it:

```bash

sudo ufw allow 20/tcp

sudo ufw allow 21/tcp

sudo ufw allow 10000:10100/tcp

sudo ufw reload

```


### Step 8: Verify the FTP server

You can now verify that the FTP server is running and listening on the expected ports:

```bash

sudo systemctl status vsftpd

```


### Step 9: Connect to the FTP server

You can test your FTP server using an FTP client. You can use command-line FTP clients like `ftp` or GUI clients like FileZilla. Here’s how to connect using the command line:

```bash

ftp your_server_ip

```

Replace `your_server_ip` with the actual IP address of your server.


### Additional Security Configurations (Optional)

For added security, consider the following optional configurations:


1. **Disable anonymous access**:

   Make sure the following line is set to `NO` in the `/etc/vsftpd.conf` file:

    ```plaintext

    anonymous_enable=NO

    ```


2. **Enable SSL/TLS**:

   To secure your FTP server with SSL/TLS, you’ll need to configure `vsftpd` to use SSL certificates.


### Conclusion

Following these steps will set up a basic FTP server using `vsftpd` on Ubuntu. Adjust the configuration further based on your security and functional requirements.

Comments