Centos 6 Simple FTP Server Setup

 

Reason:  I had recently changed VPS services but the new provider did not offer free data backup.  I was a bit bummed but the price was very cheap so I had to figure out another way.  WHM has an option in the backend to FTP backup data to a different server.  I searched around for free FTP service but they only offered up to 2gb.  If I needed more (at least 30gb in my case), I had to pay for it and I didn’t want to take on another monthly payment so I decided to create my own simple FTP server for cpanel backups.   I had 20mb connection from Comcast and since it will be running late night, I won’t notice any performance drop from my ISP.

Here is what you need:

  1. Download Centos 6.3 or the latest version  http://centos.org/
  2. Server (or computer)

The Process

  1. Go to http://centos.org/
  2. Download the iso file that will work with your server architecture. (32 or 64 bit) I use 64 bit in my case.
  3. Burn Centos onto a DVD.  In my case, I installed it as a virtual machine in ESXi VMware so I just uploaded the ISO to my server.
  4. Configure your server for raid if needed.  I bought a Dell 1950ii Power Edged server for about $150.  It came with 4x146gb hard drives.  I needed raid for data redundancy so I had it configured in RAID 5 mode.  It’s highly advised to do so in case a hard drive fails.
  5. Install Centos and use the GUI process.  Follow the instructions. NOTE:  When you get to the Network configuration screen, you need to setup a static IP.  I used this in my setup:
    1. IP = 192.168.1.100
    2. Subnet=255.255.255.0
    3. Gateway=192.168.1.1

Don’t forget to enable the network card to load on startup; otherwise the server will not have a connection on restarts.

  1. Once the server is installed, log into the server from the prompt.  Username is root.  Password is the password you created during setup.
  2. Now vsftpd needs to be installed.  Run this command below and follow through:

#yum install vsftpd

  1. Now we need to configure Vsftpd.  Run the command to open up the vsftpd.conf file in editor mode:

#vi /etc/vsftpd/vstfpd.conf

  1. Hit “i” so you can insert into the document.  Then make sure Anonymous is NO

Anonymous=NO

  1. To save and exit, click “ESC” to escape.  Then type “:x”, his enter.  This exits the doc and saves it.
  2. Now we need to turn on vsftpd during boot.  We need to invoke these commands:

#chkconfig vsftpd on

#service vsftpd start

  1.  Next we configure the IPtables.

#vi /etc/sysconfig/iptables

 

  1. Add the following to  the doc right before the one that looks just like it.  You’ll see it when you open the doc.  There’s one there with “-dport 22”.  Add it above that one, then save and exit.

-A INPUT –m state –state NEW –m tcp –p tcp –dport 21 –j ACCEPT

  1. Now we edit the iptables-config file like so:

#vi /etc/sysconfig/iptables-config

 

And make sure that IPTABLES_MODULES=”Ip_conntrack_ftp”

IPTABLES_MODULES=”Ip_conntrack_ftp”

  1. Save and close the file.
  2. Restart Firewall by invoking this command

#service iptables restart

  1. Create a user with this command:

#Useradd yourusername –d /home/yourusername

 

Then add the user password:

 

#Passwd yourusername

 

  1.  Disable SElinux by editing the file below and making sure SELINUS=Disabled

#vi /etc/selinus/config

SELINUX=Disabled

  1. Save and exit the file
  2. Restart server

#reboot

FTP to the Server remotely

  1. Connect to your router by entering the IP of the router into the browser. In my case it’s 192.168.1.1
  2. Enter in the router username/password.  If you have not changed it, look at the router manual for the user credentials.
  3. Find port forwarding in your router’s configuration.  You’ll need to map port 21, 22 to the server’s IP that you’ve configured above.  Save and exit.  You’re done with router.
  4. 4.       Open up a browser and go to google.com.  Type  “whats my IP” in the search field and hit enter.  It’ll will tell you “Your public IP address is xxx.xxx.xxx.xxx”  (the x are your IP address”)
  5. Now that you have your external WAN IP address, you can remote in from another computer out of your network…. Like from school or anywhere around the world.  In filezilla, just used the IP address that came up.   The only down fall is that if you’re on a residential broadband, your WAN IP will change periodically. 

Come back for more on linking WHM backup to this FTP server.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.