zmedia

How to enable ftp on ubuntu server



To enable ftp on your server there are a number of things you need to do as follows:

1. Install the FTP server on your Ubuntu machine. You can use the following command in the terminal for this:

sudo apt-get install vsftpd

2. Once the FTP server is installed, open the vsftpd configuration file using the following command:

sudo nano /etc/vsftpd.conf

edit this section:

. . .

# Allow anonymous FTP? (Disabled by default).

anonymous_enable=NO

#

# Uncomment this to allow local users to log in.

local_enable=YES 

write_enable=YES 

chroot_local_user=YES

allow_writeable_chroot=YES

local_root=/var/www/html

. . .

3. Allowing FTP Traffic from the Firewall

To allow the Ubuntu FTP server to communicate via the internet, it needs to make its way through the firewall. But first, let’s just see whether the firewall is already enabled on your machine or not. Simply run this command to verify the status:

sudo ufw status

If you see the following message:

ufw: command not found

It means that the firewall is not installed. You can install and enable it by typing:

sudo apt-get install ufw

sudo ufw enable

If it’s already active, you still need to make sure FTP traffic is allowed. To do that, execute the following commands one by one:

sudo ufw allow OpenSSH

sudo ufw allow 20/tcp

sudo ufw allow 21/tcp

sudo ufw allow 990/tcp

sudo ufw allow 40000:50000/tcp

This series of commands will open up several ports:

 

OpenSSH is required if you still wish to access your server via SSH. Sometimes, this option is enabled by default.

ports 20 and 21 for the FTP traffic.

ports 40000:50000 will be reserved for the range of passive ports that will eventually be set in the configuration file.

port 990 will be used when TLS is enabled.

Now let’s look at the status again:

sudo ufw status

The output should look something like this:



4. Create a user for ftp login

sudo adduser yourname

After adding the new user, you need to give them access to the FTP directory. For this, you can use the following commands:

sudo chown nobody:nogroup /home/username/ftp

here I want to remote the folder in /var/www/html, so I do this:

sudo chown nobody:nogroup /var/www/html
sudo chmod -R 755 /var/www/html

Check folder permission "ls -l /var/www/" and this output:



5. Finally, restart the FTP server with the following command:

sudo systemctl restart vsftpd

Now the new user added will have access to your Ubuntu FTP server. 

Note: Make sure to keep your server secure by limiting access only to trusted users.




Posting Komentar untuk "How to enable ftp on ubuntu server"