0% found this document useful (0 votes)
21 views5 pages

Ubuntu 22 04 FTP Server Configuration

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views5 pages

Ubuntu 22 04 FTP Server Configuration

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Page 1 of 5

Ubuntu 22.04 FTP Server Configuration

1. FTP Server is Installed

root@ubuntu:/var/www/html# apt install vsftpd -y


root@ubuntu:/var/www/html# systemctl enable vsftpd
root@ubuntu:/var/www/html# systemctl start vsftpd

2. Create or Use an Existing User

root@ubuntu:/var/www/html# adduser masud

3. Grant Directory Permissions

root@ubuntu:/var/www# chown -R masud:masud /var/www/html/


root@ubuntu:/var/www# chmod -R 775 /var/www/html/

4. Allow FTP User to Access Files

root@ubuntu:/var/www/html# vim /etc/vsftpd.conf

write_enable=YES
local_umask=022
chroot_local_user=YES
allow_writeable_chroot=YES
user_sub_token=$USER
local_root=/var/www/html
pasv_enable=YES
pasv_min_port=40000
pasv_max_port=50000
pasv_address= <My Server IP>

5. Restart the vsftpd service

root@ubuntu:/var/www/html# systemctl restart vsftpd

6. Update Firewall Rules

sudo ufw allow 21/tcp


sudo ufw allow 40000:50000/tcp
sudo ufw reload

Page 1|5
Page 2 of 5

7. Troubleshooting Tips:

• Check Server Logs: Review the FTP server logs to identify errors:

sudo tail -f /var/log/vsftpd.log

• Test Connectivity: Verify that the server is reachable:


ping 103.209.41.32

• Increase Timeout: If timeouts occur, increase the timeout settings in FileZilla:

1. Go to Edit > Settings > Connection.


2. Increase the Timeout in seconds (e.g., to 60 or 120).

• Test Active Mode (Optional): If Passive Mode issues persist, switch to Active
Mode in FileZilla:

1. Go to Edit > Settings > FTP > Transfer Mode.


2. Select Active Mode.

❖ Configure a TCP Port Range in an AWS Security Group.

1. Open the AWS Management Console

1. Go to the EC2 Dashboard.


2. Click on Security Groups in the left-hand menu under the "Network & Security"
section.

2. Select the Security Group

1. Find and select the Security Group you want to modify.


2. Go to the Inbound Rules tab (for incoming traffic) or Outbound Rules tab (for outgoing
traffic), depending on your requirements.

3. Edit the Inbound or Outbound Rules

1. Click Edit inbound rules or Edit outbound rules.


2. Click Add rule.

Page 2|5
Page 3 of 5

4. Configure the Rule

• Type: Select Custom TCP Rule.


• Protocol: Select TCP.
• Port Range: Enter the port range (e.g., 40000-50000 for Passive FTP).
• Source/Destination:
o Anywhere (0.0.0.0/0): Allows traffic from all IPs.
o My IP: Restricts access to your current IP address.
o Custom: Enter a specific CIDR block (e.g., 192.168.1.0/24).
• Click Save rules.

Example

If you're opening a port range for Passive FTP:

• Type: Custom TCP


• Protocol: TCP
• Port Range: 40000-50000
• Source: Anywhere (0.0.0.0/0) or My IP Address

This opens TCP ports 40000-50000 for all incoming IP addresses.

8. Advanced FTP Server.


For vsftpd (Very Secure FTP Daemon)

1. Edit the Configuration File: Open the vsftpd configuration file:

sudo nano /etc/vsftpd.conf

2. Change the Listening Port: Add or modify the following line to specify a new port (e.g.,
2121):

Comment # listen=NO

listen_port=2121

3. Save and Exit: Save the file (CTRL+O and CTRL+X).


4. Update Firewall Rules: Allow the new port through your firewall. For example:

• UFW:

sudo ufw allow 2121/tcp


sudo ufw reload
Page 3|5
Page 4 of 5

• iptables:

sudo iptables -A INPUT -p tcp --dport 2121 -j ACCEPT


sudo iptables-save

5. Restart vsftpd: Restart the FTP service to apply the changes:

sudo systemctl restart vsftpd

6. Inform Users: Make sure users are aware they need to connect to the new port (e.g.,
ftp://your-server-ip:2121).

9. Firewall configured rules

ufw enable

ufw allow 9722/tcp

ufw status

ufw disable

ufw reload

ufw status numbered

ufw delete 3

• Delete a Rule Directly by Port

ufw delete allow 22/tcp


ufw delete allow 40000:50000/tcp

Page 4|5
Page 5 of 5

10. Troubleshooting Tips

• Verify Passive Mode Ports: Ensure the specified Passive Mode ports (e.g., 40000–
50000) are not blocked by a firewall or router.
• Server Logs: Check the FTP server logs for additional details:

sudo tail -f /var/log/vsftpd.log

• Use Active Mode: If Passive Mode is problematic, switch to Active Mode in FileZilla:
1. Go to Edit > Settings > FTP > Transfer Mode.
2. Select Active Mode and try reconnecting.

Page 5|5

You might also like