sftpd (Very Secure FTP Daemon) is a piece of software used to implement file servers via the FTP protocol. It stands out mainly because its default values are very secure, and because of its simplicity in configuration, compared to other alternatives such as ProFTPD, and Wu-ftpd. It is currently presumed that vsftpd could be perhaps the most secure FTP server in the world.
We access /usr/local/src/
rokitoh@red-orbita:/# cd /usr/local/src/We download Vsftpd
rokitoh@red-rbita: /usr/local/src/# wget https://security.appspot.com/downloads/vsftpd-2.3.4.tar.gzWe decompress
rokitoh@red-orbita: /usr/local/src/# tar xvf vsftpd-2.3.4.tar.gzWe access the directory.
rokitoh@red-orbita: /usr/local/src/# cd vsftpd-2.3.4we install!
rokitoh@red-orbita:/vsftpd-2.3.4# make
rokitoh@red-orbita:/vsftpd-2.3.4# make install
if [ -x /usr/local/sbin ]; then \
install -m 755 vsftpd /usr/local/sbin/vsftpd; \
else \
install -m 755 vsftpd /usr/sbin/vsftpd; fi
if [ -x /usr/local/man ]; then \
install -m 644 vsftpd.8 /usr/local/man/man8/vsftpd.8; \
install -m 644 vsftpd.conf.5 /usr/local/man/man5/vsftpd.conf.5; \
elif [ -x /usr/share/man ]; then \
install -m 644 vsftpd.8 /usr/share/man/man8/vsftpd.8; \
install -m 644 vsftpd.conf.5 /usr/share/man/man5/vsftpd.conf.5; \
else \
install -m 644 vsftpd.8 /usr/man/man8/vsftpd.8; \
install -m 644 vsftpd.conf.5 /usr/man/man5/vsftpd.conf.5; fi
if [ -x /etc/xinetd.d ]; then \
install -m 644 xinetd.d/vsftpd /etc/xinetd.d/vsftpd; fiWe check that it is installed.
rokitoh@red-orbita:/vsftpd-2.3.4# ls -l /usr/local/sbin/vsftpd
-rwxr-xr-x 1 root staff 107440 nov 23 23:32 /usr/local/sbin/vsftpdWe copy the configuration file to /etc
rokitoh@red-orbita:/vsftpd-2.3.4# cp vsftpd.conf /etcConfigure vsftpd
rokitoh@red-orbita:/vsftpd-2.3.4# vi /etc/vsftpd.confanonymous_enable parameter.
Used to define whether anonymous access to the server will be allowed. Set as value YES either NO according to what is required.
anonymous_enable=NOlocal_enable parameter
It is particularly interesting if combined with the cage function (chroot). Establishes whether authenticated access from local users on the system will be allowed. Set as value YES either NO according to what is required.
local_enable=nowrite_enable parameter.
Sets whether the write command is allowed on the server. Set the value to YES or NO according to what is required.
write_enable=YESftpd_banner parameter.
This parameter is used to establish the banner that will be displayed every time a user accesses the server.
ftpd_banner= Bienvenido al servidor de Red-Orbita.es, ten cuidado con lo que tocas.anon_max_rate parameter.
It is used to limit the transfer rate in bytes per second for anonymous users, something extremely useful on publicly accessible FTP servers. The following example limits the transfer rate to 5 Kb per second for anonymous users:
anon_max_rate=5120local_max_rate parameter.
Does the same as anon_max_rate, but applies to local users of the server. The following example limits the transfer rate to 5 Kb per second for local users:
local_max_rate=5120max_clients parameter.
Establishes the maximum number of clients that can access the FTP server simultaneously. In the following example, access will be limited to 5 simultaneous clients.
max_clients=5max_per_ip parameter.
Sets the maximum number of connections that can be made from the same IP address. Keep in mind that some networks access through a proxy server or gateway and because of this some access could be unnecessarily blocked. In the following example, the number of simultaneous IP connections is limited to 5.
max_per_ip=5xferlog_enable parameter
Establishes if we want to save the LOG'S (by default it will be in /var/log).
xferlog_enable=YESchroot_* parameters
chroot are used to create and maintain a separate virtual copy of the operating system in a directory of the operating system.
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_listCreamos el fichero donde se guardara todos los usuarios que accederán mediante el ftprokitoh@red-orbita:/vsftpd-2.3.4# touch /etc/vsftpd.chroot_listWe add the following in the shell
rokitoh@red-orbita:/vsftpd-2.3.4# echo /bin/ftp >> /etc/shellsand we create /bin/ftp
rokitoh@red-orbita:/vsftpd-2.3.4# mkdir /bin/ftpAhora tocaría crear los usuarios, para ello yo he creado un pequeño script algo cutre pero funcional.
######################################################################################
######################################################################################
######################################################################################
############## SCRIPT ADMINISTRACIÓN USUARIOS FTP ##################################
##################### By rokitoh. Copyleft!!! ##################################
######################################################################################if [ $(whoami) != «root» ]; then
echo “Debes ser root para correr este script.”
echo “Para entrar como root, escribe \”su o sudo \” sin las comillas.”
exit 1
fi
while :
do
echo
echo ” Administrar Usuarios FTP”
echo “_____ ____ __________________”
echo
echo “1. Crear usuario FTP”
echo “2. Borrar usuario FTP”
echo “3. Listar usuarios FTP”
echo -n “Seleccione una opcion [1 – 3] ”
read opcion
case “$opcion” in1)
read -p “Introduzca nombre de usuario: ” user
cat /etc/passwd | grep $user > /dev/null
if [ $? -eq 0 ]
then
echo “el usuario $user ya existe”elseuseradd -m -d /home/ftp/$user -s /bin/ftp -g ftp $user; passwd $user
echo $user >> /etc/vsftpd.user_listfi;;
2)
read -p “Introduzca nombre de usuario: ” user
cat /etc/passwd | grep $user > /dev/null
if [ $? -eq 1 ]
then
echo “el usuario $user no existe”elsewhile true; do
echo
read -p “¿Estas seguro que quieres borrar el usuario? ” yn
case $yn in
yes ) break;;
no ) exit;;
* ) echo “por favor responda yes o no”;;
esac
done
userdel $user
sed ‘/$user/d’ /etc/vsftpd.user_list > /etc/vsftpd.user_list
fi;;
3)clear
echo
echo ” Usuarios disponibles”
echo “_____ ____ __________________”
echocat /etc/vsftpd.user_list
;;
*)
echo “$opcion es una opcion invalida.”
echo “Presiona una tecla para continuar…”
read foo;;esac
doneGreetings, I hope it helps you.
rokitoh!!
Comments