We are what we repeatedly do. Excellence, then, is not an act, but a habit.

Aristotle

Blog About JV Roig

How to setup a basic FTP server in CentOS and Fedora


Author's avatar

by JV Roig
on September 29, 2017



Here's a simple and easy way to setup a basic FTP server in your CentOS / Fedora machines.

I planned to run some experiments during the Christmas break (2016), so I needed to setup FTP services on all eight R&D servers I had then (that's 2 clusters of 4 servers each). The first cluster ran on CentOS 7, while the other had Fedora 25.

I was already at home then, so there's no GUI available - just a basic bash terminal c/o SSH.

Here's how I setup FTP in CentOS 7.

  1. Log in through SSH to your machine
  2. Install vsftpd:
    yum -y install vsftpd
  3. Configure vsftpd:
    
            cd /etc/vsftpd
            vi vsftpd.conf
                anonymous_enable=NO
                local_enable=YES   //already like this by default
                write_enable=YES   //already like this by default
                userlist_enable=YES //already like this by default
  4. Make sure "root" is not allowed to login:
    
            cat user_list
                root should be in the list
  5. Enable ftp service and start
    
            systemctl enable vsftpd
            systemctl start vsftpd
  6. Configure firewall to allow FTP
    
            cd /etc/firewalld/zones
            vi public.xml	//might be different on yours
            	add <service name="ftp"/> in the list of <service> tags (see below for example)
            		<zone>
            			<short></short>
            			<description>
            			</description>
            			<service />
            			<service />  <--here
            		</zone>
  7. Reload firewall
    systemctl restart firewalld

DONE!

For Fedora, the steps are practically the same, except for using dnf instead of yum, and the firewall xml file:

  1. Log in through SSH to your machine
  2. Install vsftpd:
    dnf -y install vsftpd
  3. Configure vsftpd:
    
            cd /etc/vsftpd
            vi vsftpd.conf
                anonymous_enable=NO
                local_enable=YES   //already like this by default
                write_enable=YES   //already like this by default
                userlist_enable=YES //already like this by default
  4. Make sure "root" is not allowed to login:
    
            cat user_list
                root should be in the list
  5. Enable ftp service and start
    
            systemctl enable vsftpd
            systemctl start vsftpd
  6. Configure firewall to allow FTP
    cd /etc/firewalld/zones
    vi FedoraWorkstation.xml	//this will probably be named like what the active configuration is (workstation/server/standard)
        add <service name="ftp"/> in the list of <service> tags (see below for example)
    		<zone>
    			<short></short>
    			<description>
    			</description>
    			<service />
    			<service />  <--here
    		</zone>
  7. Reload firewall
    systemctl restart firewalld

DONE!

Note that this is a very basic installation, and not very secure. Although we disallowed root and anonymous logins, we are still using an insecure protocol (plain FTP, instead of FTPS or SFTP).

For my needs, since these servers aren't production servers, they're just internal R&D servers for various experiments I run, and I connect through a VPN from home, that's really allthe security I need.

Once you successfuly get your FTP server running, you should consider looking into setting up a more secure protocol. On my next blog post, we'll talk about getting FTPS and SFTP.

Tags: Fedora 25, CentOS 7, FTP