Como instalar y configurar proftpd con mysql en Debian Lenny
1 - Instalamos proftpd con soporte mysql desde el aptitude.
apt-get install proftpd-mysql
Run proftpd from inetd or standalone? <-- standalone
2- Luego creamos el usuario y el grupo. (Reemplazamos el grupo y el id de usuario por alguno que tengamos libre).
groupadd -g 2001 ftpgroup
useradd -u 2001 -s /bin/false -d /bin/null -g ftpgroup ftpuser
3- Ahora vamos a crear la base de datos "ftp" y un usuario llamado proftpd. Con el que mysql se conectara a la base de datos.
mysql -u root -p
create database ftp;
GRANT SELECT, INSERT, UPDATE, DELETE ON ftp.* TO 'proftpd'@'localhost' IDENTIFIED BY 'password';
GRANT SELECT, INSERT, UPDATE, DELETE ON ftp.* TO 'proftpd'@'localhost.localdomain' IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
Luego creamos las tablas.
USE ftp;
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';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';
quit;
4- Ahora vamos a configurar proftpd, vamos a editar el archivo conf de proftpd.En este link hay una lista de todos los parametros de configuracion. http://www.proftpd.org/docs/directives/linked/by-name.html
Para editar el archivo de conf :
mcedit /etc/proftpd/proftpd.conf
En algunos casos el archivo puede estar en /etc/proftpd.conf
deberia quedar asi:
Include /etc/proftpd/modules.conf
UseIPv6 on
IdentLookups off
ServerName "Pro Ftpd Server"
ServerType standalone
DeferWelcome off
MultilineRFC2228 on
DefaultServer on
ShowSymlinks on
TimeoutNoTransfer 600
TimeoutStalled 600
TimeoutIdle 1200
#DisplayLogin welcome.msg
DisplayChdir .message true
ListOptions "-l"
DenyFilter \*.*/
Port 21
DefaultRoot ~
# DynMasqRefresh 28800
MaxInstances 30
User ftpuser
Group ftpgroup
Umask 022 022
#Normally, we want files to be overwriteable.
AllowOverwrite on
TransferLog /var/log/proftpd/xferlog
SystemLog /var/log/proftpd/proftpd.log
AllowRetrieveRestart on
AllowStoreRestart on
QuotaEngine off
Ratios off
DelayEngine on
ControlsEngine off
ControlsMaxClients 2
ControlsLog /var/log/proftpd/controls.log
ControlsInterval 5
ControlsSocket /var/run/proftpd/proftpd.sock
AdminControlsEngine off
# 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 ftpuser@localhost proftpd ******
# 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
CreateHome 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
RootLogin off
RequireValidShell off
Tengan en cuenta 2 cosas.
En algunas versiones de proftpd se usa el parametro CreateHome en vez de SQLHomedirOnDemand por eso lo deje comentado.
En SQLConnectInfo van los datos de la base de datos de mysql que creamos anteriormente
Una vez que terminamos de editar el .conf, tenemos que descomentar en modules.conf los modulos de sql que estan comentados.
Lo que quedaria algo asi:
mcedit /etc/proftpd/modules.conf
#
# This file is used to manage DSO modules and features.
#
# This is the directory where DSO modules reside
ModulePath /usr/lib/proftpd
# Allow only user root to load and unload modules, but allow everyone
# to see which modules have been loaded
ModuleControlsACLs insmod,rmmod allow user root
ModuleControlsACLs lsmod allow user *
LoadModule mod_ctrls_admin.c
LoadModule mod_tls.c
# Install proftpd-mod-mysql or proftpd-mod-pgsql to use this
LoadModule mod_sql.c
# Install proftpd-mod-ldap to use this
#LoadModule mod_ldap.c
#
# 'SQLBackend mysql' or 'SQLBackend postgres' directives are required
# to have SQL authorization working. You can also comment out the
# unused module here, in alternative.
#
# Install proftpd-mod-mysql to use this
LoadModule mod_sql_mysql.c
# Install proftpd-mod-pgsql to use this
#LoadModule mod_sql_postgres.c
LoadModule mod_radius.c
LoadModule mod_quotatab.c
LoadModule mod_quotatab_file.c
# Install proftpd-mod-ldap to use this
#LoadModule mod_quotatab_ldap.c
# Install proftpd-mod-pgsql or proftpd-mod-mysql to use this
LoadModule mod_quotatab_sql.c
LoadModule mod_quotatab_radius.c
LoadModule mod_wrap.c
LoadModule mod_rewrite.c
LoadModule mod_load.c
LoadModule mod_ban.c
LoadModule mod_wrap2.c
LoadModule mod_wrap2_file.c
# Install proftpd-mod-pgsql or proftpd-mod-mysql to use this
#LoadModule mod_wrap2_sql.c
LoadModule mod_dynmasq.c
# keep this module the last one
LoadModule mod_ifsession.c
5 - Creamos los usuarios en mysql.
Nos conectamos a mysql y creamos el grupo en la tabla ftpgroup que contienen el nombre del grupo el id y el nombre de usuario que creamos anteriormente
mysql -u root -p
USE ftp;
INSERT INTO `ftpgroup` (`groupname`, `gid`, `members`) VALUES ('ftpgroup', 2001, 'ftpuser');
Ahora hacemos un insert de un nuevo usuario
INSERT INTO `ftpuser` (`id`, `userid`, `passwd`, `uid`, `gid`, `homedir`, `shell`, `count`, `accessed`, `modified`) VALUES (1, 'exampleuser', 'secret', 2001, 2001, '/home/newuser', '/sbin/nologin', 0, '', '');
quit;
Iniciamos Proftpd
/etc/init.d/proftpd start
Hacemos un ls en el home y vemos como se creo un nuevo directorio con el nombre de nuestro usuario.
ls -l /home
Ya tenemos configurado proftpd y listo para usarlo. Ahora si queremos agregar proftp al incio de linux ejectuamos el siguiente comando (en debian):
ln -s /etc/init.d/proftpd /etc/rcX.d/S20proftpd
Donde X sera nuestro runlevel, para saber cual es nuestro runlevel ejecutamos.
cat /etc/inittab | grep id
El resultado es algo asi:
id:X:initdefault:
Y eso es todo. Si a alguien le trae problemas la instalacion son bienvenidos de comentar.
viernes, 15 de mayo de 2009
Configurando PROFTPD con Mysql en Debian
Etiquetas:
configuracion,
ftp,
linux,
proftpd,
proftpd en debian,
servidor ftp
Suscribirse a:
Enviar comentarios (Atom)
Felicitaciones por el tutorial, cuando uso el cliente ftp entra sin problemas, pero solo puedo ver el contenido, no puedo subir o eliminar archivos.
ResponderEliminar