Logo
  • Entries
  • Comments
  • Popular
Recent Posts
  • January 2012
  • November 2011
  • October 2011
  • September 2011
  • August 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
  • March 2011
  • February 2011
  • January 2011
  • December 2010
  • November 2010
  • October 2010
  • September 2010
  • August 2010
  • July 2010
  • June 2010
  • May 2010
  • April 2010
  • March 2010
  • February 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • August 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • October 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008
  • December 2007
  • November 2007
  • October 2007
  • July 2007
Recent Comments
  • Makendra It's always a pleasure to hear from someone with eexrpitse....
  • Rubén Ortiz Hola dependerá de varias cosas pero la respuesta sería NO. ...
  • jose miguel perea Buenos días, ¿La replicación entre maestro y esclavo es i...
  • Rubén Ortiz Si lo hacéis legal, con VMware el único problema son los cos...
  • Angel Hola, estamos valorando implementar baremetal para crear un ...
Popular Articles
  • Declaro la guerra al mosquito Tigre (35)
  • Phpbb3 - encode error converter (19)
  • MySQL - Variables básicas a configurar (17)
  • Reinicio programado Windows 2003 Server (16)
  • Plesk - Evitar el SPAM (10)
  • Home
  • Contacta
  • Hosting Linux
  • Legal
  • Sobre mí – About me

Centos 5 – ProFTPd y MySQL

Posted by Rubén Ortiz on Oct 28, 2008 in Centos, Linux | 3 comments

Voy a comentar cuatro sencillos pasos para montar el ya archiconocido ProFTPd con autenticación y quotas de espacio por MySQL. La verdad es que tenía el gusanillo de montarlo como prueba, para uso personal y quizá como un servicio que poder ofrecer. Cada vez vamos más hacia servicios permanentes, de no depender en exceso de hardware propio y más de servicios externos, como podría ser un FTP.

Primero, para bajarnos el software de ProFTPd necesitamos un repositorio adicional para CentOS, editamos el fichero de yum y añadimos lo siguiente:

1
<strong># vim /etc/yum.repos.d/CentOS-Base.repo</strong>
1
2
3
4
5
6
7
8
9
10
11
# Name: RPMforge RPM Repository for Red Hat Enterprise 5 - dag
# URL: http://rpmforge.net/
[RHEL5-rpmforge]
name = Red Hat Enterprise 5 - RPMforge.net - dag
#baseurl = http://apt.sw.be/redhat/el5/en/i386/dag
mirrorlist = http://apt.sw.be/redhat/el5/en/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 1
protect = 0
#gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 0

Instalamos mysql y mysq-server. También necesitamos apache y php para la gestión de la BD con phpmyAdimin

1
2
<strong># yum install mysql mysql-server php php-mysql httpd proftpd-mysql
</strong>

Bajamos el software de phpmyadmin y ya lo tenemos todo.

1
2
<strong># wget http://heanet.dl.sourceforge.net/sourceforge/phpmyadmin/
phpMyAdmin-2.11.9.2-all-languages.tar.gz</strong>

Añadimos usuario y grupo de sistema

1
2
3
4
5
<strong>
# groupadd -g 2008 ftpgroup
# useradd -u 2008 -s /bin/false -d /bin/null -c "usuario proftpd"
-g ftpgroup ftpuser
</strong>

Damos un password de root a la BD

1
<strong># mysqladmin -u root password tupassworderoooot</strong>

Accedemos por shell a la BD

1
2
3
4
5
6
7
8
9
# mysql -uroot -p
# mysql&gt; create database ftp;
# mysql&gt; GRANT SELECT, INSERT, UPDATE, DELETE ON ftp.* TO 'proftpd'@'localhost'
IDENTIFIED BY 'password';
# mysql&gt; use ftp;
# mysql&gt; CREATE TABLE ftpgroup ( groupname varchar(16) NOT NULL default '',
gid smallint(6) NOT NULL default '5500',
members varchar(16) NOT NULL default '',
KEY groupname (groupname)) TYPE=MyISAM COMMENT='ProFTP group table';
1
2
3
4
5
6
7
8
9
10
# mysql&gt; CREATE TABLE ftpquotalimits ( name varchar(30) default NULL,
quota_type enum('user','group','class','all') NOT NULL default 'user',
per_session enum('false','true') NOT NULL default 'false',
limit_type enum('soft','hard') NOT NULL default 'soft',
bytes_in_avail int(10) unsigned NOT NULL default '0',
bytes_out_avail int(10) unsigned NOT NULL default '0',
bytes_xfer_avail int(10) unsigned NOT NULL default '0',
files_in_avail int(10) unsigned NOT NULL default '0',
files_out_avail int(10) unsigned NOT NULL default '0',
files_xfer_avail int(10) unsigned NOT NULL default '0') TYPE=MyISAM;
1
2
3
4
5
6
7
8
# mysql&gt; CREATE TABLE ftpquotatallies ( name varchar(30) NOT NULL default '',
quota_type enum('user','group','class','all') NOT NULL default 'user',
bytes_in_used int(10) unsigned NOT NULL default '0',
bytes_out_used int(10) unsigned NOT NULL default '0',
bytes_xfer_used int(10) unsigned NOT NULL default '0',
files_in_used int(10) unsigned NOT NULL default '0',
files_out_used int(10) unsigned NOT NULL default '0',
files_xfer_used int(10) unsigned NOT NULL default '0') TYPE=MyISAM;
1
2
3
4
5
6
7
8
9
10
11
# mysql&gt; CREATE TABLE ftpuser ( id int(10) unsigned NOT NULL auto_increment,
userid varchar(32) NOT NULL default '',
passwd varchar(32) NOT NULL default '',
uid smallint(6) NOT NULL default '5500',
gid smallint(6) NOT NULL default '5500',
homedir varchar(255) NOT NULL default '',
shell varchar(16) NOT NULL default '/sbin/nologin',
count int(11) NOT NULL default '0',
accessed datetime NOT NULL default '0000-00-00 00:00:00',
modified datetime NOT NULL default '0000-00-00 00:00:00',
PRIMARY KEY (id),UNIQUE KEY userid (userid)) TYPE=MyISAM COMMENT='ProFTP user table';

Ya tenemos preparada la BD para la gestión de los usuarios FTP, ahora hay que configurar ProFTPd. Editamos el fichero de configuracion de Proftpd, hemos de cambiar el password por el password del usurio mysql que hemos creado.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
[...]
# SQL authentication Dynamic Shared Object (DSO) loading
# See README.DSO and howto/DSO.html for more details.
LoadModule mod_sql.c
LoadModule mod_sql_mysql.c
LoadModule mod_quotatab.c
LoadModule mod_quotatab_sql.c
# The passwords in MySQL are encrypted using CRYPT
SQLAuthTypes            Plaintext Crypt
SQLAuthenticate         users groups
# used to connect to the database
# databasename@host database_user user_password
SQLConnectInfo  ftp@localhost proftpd password &lt; --- cambiar!!
# Here we tell ProFTPd the names of the database columns in the "usertable"
# we want it to interact with. Match the names with those in the db
SQLUserInfo     ftpuser userid passwd uid gid homedir shell
# Here we tell ProFTPd the names of the database columns in the "grouptable"
# we want it to interact with. Again the names match with those in the db
SQLGroupInfo    ftpgroup groupname gid members
# set min UID and GID - otherwise these are 999 each
SQLMinID        500
# create a user's home directory on demand if it doesn't exist
SQLHomedirOnDemand on
# Update count every time user logs in
SQLLog PASS updatecount
SQLNamedQuery updatecount UPDATE "count=count+1, accessed=now()
WHERE userid='%u'" ftpuser
# Update modified everytime user uploads or deletes a file
SQLLog  STOR,DELE modified
SQLNamedQuery modified UPDATE "modified=now() WHERE userid='%u'" ftpuser
# User quotas
# ===========
QuotaEngine on
QuotaDirectoryTally on
QuotaDisplayUnits Mb
QuotaShowQuotas on
SQLNamedQuery get-quota-limit SELECT "name, quota_type, per_session,
limit_type, bytes_in_avail, bytes_out_avail,
bytes_xfer_avail, files_in_avail, files_out_avail,
files_xfer_avail FROM ftpquotalimits WHERE name = '%{0}' AND quota_type = '%{1}'"
SQLNamedQuery get-quota-tally SELECT "name, quota_type, bytes_in_used, bytes_out_used,
bytes_xfer_used, files_in_used, files_out_used,
files_xfer_used FROM ftpquotatallies WHERE name = '%{0}' AND quota_type = '%{1}'"
SQLNamedQuery update-quota-tally UPDATE
"bytes_in_used = bytes_in_used + %{0}, bytes_out_used = bytes_out_used + %{1},
bytes_xfer_used = bytes_xfer_used + %{2}, files_in_used = files_in_used + %{3},
files_out_used = files_out_used + %{4},
files_xfer_used = files_xfer_used + %{5}
WHERE name = '%{6}' AND quota_type = '%{7}'" ftpquotatallies
SQLNamedQuery insert-quota-tally INSERT "%{0}, %{1}, %{2},
%{3}, %{4}, %{5}, %{6}, %{7}" ftpquotatallies
QuotaLimitTable sql:/get-quota-limit
QuotaTallyTable sql:/get-quota-tally/update-quota-tally/insert-quota-tally
RootLogin off
RequireValidShell off
[...]

He tenido que poner saltos de línea en las variables de SQL, tenlo en cuenta. Ahora toca reiniciar el servicio para hacer efectivos los cambios

1
<strong># /etc/init.d/proftpd restart</strong>

Añadimos ahora un usuario de ejemplo, para añadirlo, hemos de conectarnos al MySQL por shell o phpmyadmin :)

1
# mysql -u root -p

# USE ftp;

Primero creamos una fila en la tabla ftpgroup. Esta contiene el nombre del grupo, el id del grupo y el usuario ftp de sistema que hemos creado anteriormente.

1
2
# INSERT INTO `ftpgroup` (`groupname`, `gid`, `members`)
VALUES ('ftpgroup', 2008, 'ftpuser');

Ahora, siempre que queramos añadir un nuevo usuario, sólo habremos de modificar dos tablas, ftpquotalimits y ftpuser. El usuario de ejemplo se llama pepe y tiene una restricción de 1 GB(en bytes).

1
2
3
4
# mysql&gt; INSERT INTO `ftpquotalimits`
(`name`, `quota_type`, `per_session`, `limit_type`, `bytes_in_avail`,
`bytes_out_avail`, `bytes_xfer_avail`, `files_in_avail`, `files_out_avail`, `files_xfer_avail`)
VALUES ('pepe', 'user', 'true', 'hard', 1073741824, 0, 0, 0, 0, 0);
1
2
3
4
# mysql&gt; INSERT INTO `ftpuser`
(`id`, `userid`, `passwd`, `uid`, `gid`, `homedir`, `shell`, `count`,
`accessed`, `modified`)
VALUES (1, 'pepe', 'secret', 2008, 2008, '/home/pepe', '/sbin/nologin', 0, '', '');
1
#mysql&gt; quit;


  • http://www.howtoforge.com/virtual_hosting_with_proftpd_and_mysql_fedora7
  • http://www.wains.be/index.php
  • http://www.carlosatares.com/2006/09/01/proftpdmysqlquotas/

3 Responses to “Centos 5 – ProFTPd y MySQL”

  1. Javier M says:
    9 de July, 2009 at 5:40 pm

    Hola.

    Muchísimas gracias por este post, gracias a ti he podido instalar el maldito proftpd en un CentOs 5 después de 3 horas buscando la última versión.

    Gracias, mil gracias.

    Javier.

  2. Otto Oviedo says:
    12 de February, 2010 at 11:38 pm

    Saludos gracias por el tuto, lei que había un problema al momento de arrancar el PROFTPD por esto ‘SQLHomedirOnDemand’ on line 93 of ‘/etc/proftpd.conf’ queria saber si puedes hacer un mini manual para crear el directorio home porque por mas que leo la solucion del fabricante (asi es creo) no le entiendo y estoy barado con este ftp
    muchas gracias

  3. Rod C.Pan says:
    14 de April, 2011 at 12:36 am

    Quisiera añadir la ruta /etc/www/html para subir los archivos de un sitio Web, pero los usuarios creados no me dejan acceder a tal directorio, y no lo veo desde ftp. ¿Alguna sugerencia?

Leave a Reply

Click here to cancel reply.

Nube de Tags

apache bare metal benchmark cacti centos dell drupal esxi General gripe A Hardware humor IIS kayako Linux lpi lyric Lyrics memcached mysql nginx openfiler OpenVZ openx Parallels php Phpbb plesk postgresql proftpd raid SQL Server ssh svn trac ubuntu varnish Virtualizacion Virtuozzo Virtuozzo Linux Warphammer.net Windows windows 2003 wordpress zabbix

Categorias

  • 2003 Server
  • Apache 2.X
  • benchmark
  • Centos
  • Cuanto (Luser) Cabron
  • ESXi
  • General
  • Hardware
  • IIS
  • Lighttpd
  • Linux
  • Lyrics
  • MySql
  • Nginx
  • OpenVZ
  • Parallels
  • Parallels Bare Metal
  • Php
  • Phpbb
  • Plesk
  • PostgreSQL
  • Prestashop
  • Software
  • SQL SERVER
  • Ubuntu
  • Varnish
  • Virtualizacion
  • Virtuozzo
  • Virtuozzo Windows
  • VMWare
  • Warphammer.net
  • Windows
  • Wordpress

Blogroll

  • David Toribio
  • EasyCompany.es
  • Marius Duch
  • Series
  • Warphammer.net

Recursos

  • Backup Plesk9
  • CentOS 5 32 bits RPMs
  • CentOS 5 64 bits RPMs
  • Lighttpd
  • MySQL Tunner
  • OpenVZ – Panel – PROXMOX
  • OpenVZ – Panel – VTONF
  • OpenVZ Wiki
  • Parallels Virtual Automation Resources
  • Plesk 8 Docs
  • Plesk 9 Docs
  • Plesk Hacker
  • Port80 – Compression Check
  • Virtuozzo DOCS
  • Virtuozzo Lin Commands
  • Virtuozzo Win Commands
  • Virtuozzo Windows Docu

Meta

  • Log in
  • Entries RSS
  • Comments RSS
  • WordPress.org
Designed by Elegant Themes | Powered by Wordpress