Tuesday, 10 September 2013

How to Install Pure-FTPd On CentOS 6.4

Source: http://www.servermom.com/how-to-install-pure-ftpd-on-centos-6-4/789/

How to Install Pure-FTPd On CentOS 6.4

This article teaches you how to install free ftp server Pure-FTPd on CentOS 6 and how to configure and use it so you can access your server via ftp connection using your favorite ftp client (e.g:FileZilla). The main reason why I post this article is because a friend of mine asked me why couldn’t he access his server using FileZilla. The answer is simple, that’s because he didn’t install any ftp server on his VPS. FileZilla is an ftp server installed in client computer while the VPS is not accessible via FTP without any FTP server installed. Yet, CentOS is not coming with FTP server installed by default and even if by any chance you found it installed, you still have to configure it.

What is Pure-FTPd?

Pure-FTPd is a free (BSD), secure, production-quality and standard-conformant FTP server. It doesn’t provide useless bells and whistles, but focuses on efficiency and ease of use. It provides simple answers to common needs, plus unique useful features for personal users as well as hosting providers.
Why Pure-FTPd?
Because it is actively supported, and it was always designed with security in mind, and the code is always re-audited as new kind of vulnerabilities are discussed.
Are there any other alternatives?
Yes there are. Try Pro-FTPd and vsftpd (how to install vsftpd).

How to Install Pure-FTPd on CentOS 6?

The guide is below. But first, read some prerequisites:

What You’ll Need?

  1. A Linux server running CentOS 6. In this guide I use CentOS 6.4 x64 by DigitalOcean.
  2. You better firstly setup LAMP or LNMP on it.
  3. You’ll also need an FTP client like FileZilla installed on your computer. This is for testing purpose (and you’ll really need this once you build your site)
  4. A skill to use SSH and basic Unix commands (I’m sure you have this already).
  5. About 15 minutes of your time

A. Installing Pure-FTPd Software on CentOS Server

Step 1 – Login to your server and follow my previous guide about Basic setup for CentOS before you build a live web server. You may and may not follow that tutorial but if you followed, it will give you some basic security tweak to your server.
Before you proceed to the next steps, it is better to explain that all commands in this tutorial are written without the “sudo” prefix. However if you disabled root login and you logged in using another username with root privilege, you can add the “sudo” prefix all by your self. Alternatively you can simply type su, hit Enter and type in your password twice to switch login as root.
switch-root-login
You may also need to type this command to go to the root directory:
1
cd ~
Step 2 – Pure-FTPd is not available by default in CentOS and you have to grab it from another repository. You have to enable the RPMforge and EPEL repositories on our CentOS. So go ahead add the repo:
1
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
then
1
rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
now..
1
2
3
cd /tmp
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
However If the above link doesn’t work anymore, you can find the current version of rpmforge-release here: http://packages.sw.be/rpmforge-release/.
This repo will also give you more benefit:
1
rpm --import https://fedoraproject.org/static/0608B895.txt
then
1
2
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
rpm -ivh epel-release-6-8.noarch.rpm
next, update yum:
1
yum update
Each time yum asks you to confirm, simply type Y then hit Enter.
Step 3 – Now install Pure-FTPd via yum using this command:
1
yum install pure-ftpd
screenshot:
yum install pureftpd

B. Configuring Pure-FTPd (post install)

Step 1 – Go to Pure-FTPd config folder:
1
cd /etc/pure-ftpd/
Step 2 – Next, edit the config file "pure-ftpd.conf": (in this example I use Nano editor).
1
nano -w pure-ftpd.conf
Step 3 – Once Nano editor appears with pure-ftpd.conf file ready for editing, now make adjustment to several lines as below:
3.1. Look for #UnixAuthentication and uncomment that line (remove the # symbol):
unixauth
3.2. Then change No in VerboseLog to yes.
verboselog
3.3. Uncomment the PureDB line:
purdedb
3.4. Uncomment the CreateHomeDir line
createhomedir
Step 4 – Now create ftp user or aka virtual user used to login to your server. And the command syntax is:
1
pure-pw useradd ftpuser -u user -g group -d /var/www/domain.com/public_html
where:
  1. ftpuser is username you can use it to login to your server via ftp.
  2. user is a Unix user. If you didn’t created one yet, you can also use root.
  3. group is a Unix group. If you didn’t created one yet, you can also use root.
  4. /var/www/domain.com/public_html is default document root folder of your site. This is where the ftp user will have access to once logged in.
Obviously you have to change those parts to suite your own. In my example is:
1
pure-pw useradd servermom -u sawiyati -g sawiyati -d /var/www/servermom.com/public_html
Once hit Enter, you’ll then be asked to define new password for the user. Enter it twice for confirmation.
Step 5 – Finally, issue this command:
1
pure-pw mkdb
screenshot for step 4 and 5:
purepw

C. Using FTP to Access Your Server

Step 1 – Once you’ve done making some adjustments to pure-ftpd configuration, now you better firstly restart the ftp service:
1
service pure-ftpd restart
screenshot
restart ftp
Don’t panic if you see [FAILED] message in when the system tried to stop pure-ftpd. It happens because pure-ftpd service is not yet started. The point here is the [OK] message when starting.
Step 2 – Now open up your favorite ftp client like FileZilla then enter the detail:
  • Host : Enter your server’s IP or hostname (if you’ve added A record to it in your DNS).
  • Username : Use what you defined in step 4 section B above.
  • Password : Use what you defined in step 5 section B above.
  • Port : use Port 21
Once done hit the Connect button. screenshot:
using filezilla
Step 3 – You’ll finally see the “Status:Directory listing successful” message indicating you are now logged in.
filezilla ftp
That’s it. I’m sure you knew what you have to do from here. Enjoy..

Optional

Issue this command to make sure pure-ftpd service will be automatically started every time your server reboot:
1
chkconfig --levels 235 pure-ftpd on
Also, if you created other virtual users (and passwords) – see section B step 4 – make sure you issue this command:
1
pure-pw mkdb
You have to issue that command every time you add a virtual user.

No comments: