Tema:
A raíz de la pregunta del foro Configuracion FTP me nació la curiosidad de saber si la solución que propuse funcionaba o no.
Es por eso que el presente post muestra como crear Usuario "put only" en VSFtpd:
-
IMPORTANTE: Estoy partiendo del hecho de que tengo instalado un VSFtpd (vsftpd-2.0.5-16.el5_6.1) sobre un CentOS release 5.6 (Final) con la siguiente configuración en vsftpd.conf:
anonymous_enable=NO
xferlog_file=/var/sites/ftp_misitio_com_ec/logs/vsftpd.log
ftpd_banner=Bienvenido al Servidor FTP de Iknaxio.
chroot_local_user=YES
chroot_list_enable=NO
use_localtime=YES
Procedimiento:
Creamos nuestro usuario de prueba y le asignamos una clave:
useradd -s /sbin/nologin iknaxio
passwd iknaxio
Editamos el archivo /etc/vsftpd/vsftpd.conf y agregamos la sgte linea:
user_config_dir=/etc/vsftpd/user_conf
Esta directiva permite crear una configuración específica para cada usuario especificado, sobreescribiendo la configuración global de vsftpd.conf:
[quote]
user_config_dir
This powerful option allows the override of any config option specified in the manual page, on a per-user basis. Usage is simple, and is best illustrated with an example. If you set user_config_dir to be /etc/vsftpd_user_conf and then log on as the user "chris", then vsftpd will apply the settings in the file /etc/vsftpd_user_conf/chris for the duration of the session. The format of this file is as detailed in this manual page! PLEASE NOTE that not all settings are effective on a per-user basis. For example, many settings only prior to the user's session being started. Examples of settings which will not affect any behviour on a per-user basis include listen_address, banner_file, max_per_ip, max_clients, xferlog_file, etc.
Default: (none)
[/quote]
Creamos el directorio para la configuración de usuarios:
mkdir /etc/vsftpd/user_conf
Creamos el archivo de configuración específico para el usuario iknaxio:
touch /etc/vsftpd/user_conf/iknaxio
Lo editamos y dentro colocamos la siguiente opción:
cmds_allowed=PUT,PASV,SYST,STOR,TYPE,QUIT
Finalmente hacemos un reinicio del servicio:
/etc/init.d/vsftpd restart
Y a probar:
ftp -d 127.0.0.1
El -d es para que nos imprima los comandos que se envian al servidor:
Connected to 127.0.0.1.
220 Bienvenido al Servidor FTP del FCME.
ftp: setsockopt: Bad file descriptor
---> AUTH GSSAPI
530 Please login with USER and PASS.
---> AUTH KERBEROS_V4
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (127.0.0.1:root): iknaxio
---> USER iknaxio
331 Please specify the password.
Password:
---> PASS XXXX
230 Login successful.
cmds.c:276: verbose=1 debug=1 overbose=1
---> SYST
215 UNIX Type: L8
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> put phplist.zip
local: phplist.zip remote: phplist.zip
---> TYPE I
200 Switching to Binary mode.
---> PASV
227 Entering Passive Mode (127,0,0,1,201,231)
---> STOR phplist.zip
150 Ok to send data.
226 File receive OK.
3443056 bytes sent in 0.011 seconds (3e+05 Kbytes/s)
Y ahora probamos las restricciones:
ftp> get phplist.zip
local: phplist.zip remote: phplist.zip
---> PASV
227 Entering Passive Mode (127,0,0,1,220,239)
---> RETR phplist.zip
550 Permission denied.
ftp> ls
---> TYPE A
200 Switching to ASCII mode.
---> PASV
227 Entering Passive Mode (127,0,0,1,135,130)
---> LIST
550 Permission denied.
ftp> mkdir amirak
---> MKD amirak
550 Permission denied.
ftp> quit
---> QUIT
221 Goodbye.
Salu2 8)
Comentarios
Cool, ese VSFTP es una
Cool, ese VSFTP es una máquina de server FTP, sabía que lo había visto por algún lado el como hacerlo, y si a eso le agregas autenticación desde una base de datos, queda más mejor :D ...
bye
;)
Cuando tenga
Cuando tenga tiempo voy a intentar lo de la autencación :D
"Transporta un puñado de tierra todos los días y construirás una montaña" - Confucio
floss.iknaxio.net