Instalar ProFTPD en UBUNTU
sudo apt-get install proftpd
abrir los puertos en el firewall
sudo ufw allow 20/tcp
sudo ufw allow 21/tcp
sudo ufw allow 990/tcp
sudo ufw allow 40000:50000/tcp
revisar el estado del firewall
sudo ufw status
si esta parado el firewall
sudo ufw enable
Status del Servidor
sudo systemctl start proftpd
sudo systemctl enable proftpd
Configuracion de proftpd
sudo nano /etc/proftpd/proftpd.conf
verificamos que esten descomentadas las lineas
ServerName "Mi servidor"
DefaultRoot ~
reiniciamos el proftpd
sudo systemctl restart proftpd
editamos el archivo shells para agregar un fake shell
sudo nano /etc/shells
agregar al final
/bin/false
Creamos un usuario con acceso al directorio html
sudo useradd -d /var/www/html -g www-data -s /bin/false USUARIO sudo passwd USUARIO sudo -u USUARIO ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/var/www/USUARIO/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /var/www/USUARIO/.ssh/id_rsa.
Your public key has been saved in /var/www/USUARIO/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:Av0gy83/HQZNLaPzeU+orJM8CT/t+PiHAu1loazIyB4 bkp@XXXXXXXXXX
The key's randomart image is:
+---[RSA 2048]----+
| |
| . . |
| o o + . |
| . * o +.o |
| o + So+... |
| oo ++o. . |
| .Eo ..B *=.o .|
| o.o ..@*o+.o |
| .. =XB. .|
+----[SHA256]-----+
Crear el directorio para guardar las claves
mkdir /etc/proftpd/authorized_keys/
Convertiremos la llave en el formato RFC4716 y la pondremos dentro de la carpeta del ProFTPd:
sudo ssh-keygen -e -f /var/www/USUARIO/.ssh/id_rsa.pub | tee /etc/proftpd/authorized_keys/USUARIO
sudo cp /var/www/USUARIO/.ssh/id_rsa ~/USUARIO.pem
Creamos la configuracion para sftp
sudo nano /etc/proftpd/conf.d/sftp.conf
seguramente el archivo no existe, asi que se debe copiar el siguiente texto
<IfModule mod_sftp.c>
SFTPEngine on
Port 2222
SFTPLog /var/log/proftpd/sftp.log
# Configure both the RSA and DSA host keys, using the same host key
# files that OpenSSH uses.
SFTPHostKey /etc/ssh/ssh_host_rsa_key
SFTPHostKey /etc/ssh/ssh_host_dsa_key
SFTPAuthMethods publickey
SFTPAuthorizedUserKeys file:/etc/proftpd/authorized_keys/%u
# Enable compression
SFTPCompression delayed
</IfModule>
Error fatal: SFTPHostKey: unable to check ‘/etc/ssh/ssh_host_dsa_key’: No existe el archivo
ssh-keygen -f /etc/ssh/ssh_host_dsa_key -N '' -t dsa