Home Linux & Systems Cybersecurity Cloud & DevOps Networks & Infrastructure SIEM & Monitoring DFIR & Threat Intel Development & Other All categories Projects About Tools

HowTo: Install vsftpd GNU/Linux

Leer en espanol
HowTo: Install vsftpd GNU/Linux

Table of contents

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/

Bash
rokitoh@red-orbita:/# cd /usr/local/src/

We download Vsftpd

Bash
rokitoh@red-rbita: /usr/local/src/# wget  https://security.appspot.com/downloads/vsftpd-2.3.4.tar.gz

We decompress

Bash
rokitoh@red-orbita: /usr/local/src/# tar xvf vsftpd-2.3.4.tar.gz

We access the directory.

Bash
rokitoh@red-orbita: /usr/local/src/# cd  vsftpd-2.3.4

we install!

Bash
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; fi

We check that it is installed.

Bash
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/vsftpd

We copy the configuration file to /etc

Bash
rokitoh@red-orbita:/vsftpd-2.3.4# cp vsftpd.conf /etc

Configure vsftpd

Bash
rokitoh@red-orbita:/vsftpd-2.3.4# vi /etc/vsftpd.conf

anonymous_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.

text
anonymous_enable=NO

local_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.

text
local_enable=no

write_enable parameter.


Sets whether the write command is allowed on the server. Set the value to YES or NO according to what is required.

text
write_enable=YES

ftpd_banner parameter.


This parameter is used to establish the banner that will be displayed every time a user accesses the server.

text
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:

text
anon_max_rate=5120

local_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:

text
local_max_rate=5120

max_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.

text
max_clients=5

max_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.

text
max_per_ip=5

xferlog_enable parameter

Establishes if we want to save the LOG'S (by default it will be in /var/log).

text
xferlog_enable=YES

chroot_* parameters

chroot are used to create and maintain a separate virtual copy of the operating system in a directory of the operating system.

text
chroot_local_user=YES

chroot_list_enable=YES

chroot_list_file=/etc/vsftpd.chroot_list
text
Creamos el fichero  donde se guardara todos los usuarios que accederán mediante el ftp
Bash
rokitoh@red-orbita:/vsftpd-2.3.4# touch /etc/vsftpd.chroot_list

We add the following in the shell

Bash
rokitoh@red-orbita:/vsftpd-2.3.4# echo /bin/ftp >> /etc/shells

and we create /bin/ftp

Bash
rokitoh@red-orbita:/vsftpd-2.3.4# mkdir /bin/ftp

Ahora tocaría crear los usuarios, para ello yo he creado un pequeño script algo cutre pero funcional.

Bash
######################################################################################

######################################################################################

######################################################################################

############## SCRIPT ADMINISTRACIÓN USUARIOS FTP  ##################################

##################### By rokitoh. Copyleft!!! ##################################

######################################################################################
Bash
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” in
Bash
1)

read -p “Introduzca nombre de usuario: ” user

cat /etc/passwd | grep $user > /dev/null

if [ $? -eq 0 ]

then

echo “el usuario $user ya existe”
text
else
Bash
useradd -m -d /home/ftp/$user -s /bin/ftp -g ftp $user; passwd $user

echo $user >> /etc/vsftpd.user_list
Bash
fi
Bash
;;

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”
text
else
Bash
while 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
text
;;

3)

Bash
clear

echo

echo ” Usuarios disponibles”

echo “_____ ____ __________________”

echo
Bash
cat /etc/vsftpd.user_list

;;

*)

echo “$opcion es una opcion invalida.”

echo “Presiona una tecla para continuar…”

read foo;;
Bash
esac

done

Greetings, I hope it helps you.
rokitoh!!

Comments