PureFTPd – Chroot para diretórios virtuais
Sempre que faço a instalação de um servidor PureFTPD, quando vou testar o acesso, noto que o diretório inicial do cliente está com o path físico real sendo mostrado.. assim:
[plain]
Connected to servidor.
220———- Welcome to Pure-FTPd [privsep] [TLS] ———-
220-You are user number 1 of 50 allowed.
220-Local time is now 10:42. Server port: 21.
220-This is a private system – No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name (servidor:user): usuario
331 User usuario OK. Password required
Password:
230 OK. Current directory is /home/usuario
Remote system type is UNIX.
[/plain]
Como não quero isso, vou atrás de fechar esse acesso…
o Pureftpd (pelo menos no Debian) cria a seguinte estrutura para os arquivos de configuração:
[plain]
cd /etc/pure-ftpd/conf
root@servidor:/etc/pure-ftpd/conf# ls -l
total 40
-rw-r–r– 1 root root 36 Feb 25 2015 AltLog
-rw-r–r– 1 root root 6 Feb 25 2015 FSCharset
-rw-r–r– 1 root root 5 Feb 25 2015 MinUID
-rw-r–r– 1 root root 29 Feb 25 2015 MySQLConfigFile
-rw-r–r– 1 root root 4 Feb 25 2015 NoAnonymous
-rw-r–r– 1 root root 4 Feb 25 2015 PAMAuthentication
-rw-r–r– 1 root root 28 Feb 25 2015 PureDB
-rw-r–r– 1 root root 18 Feb 25 2015 TLSCipherSuite
-rw-r–r– 1 root root 3 Feb 25 2015 UnixAuthentication
root@servidor:/etc/pure-ftpd/conf#
[/plain]
Note que cada arquivo, representa o nome de um ‘wrapper’ (pacote), que nesse caso, representa uma configuração opcional específica. A lista completa dos wrappers pode ser vista nas man pages (sim, elas ainda existem! – menos Google e mais man):
[plain]man pure-ftpd-wrapper[/plain]
Os wrappers são divididos por tipos com valores, como Boleanos, Numéricos, String, etc..
Enfim, na lista, vamos procurar o whapper: ‘ChrootEveryone’, que possui valor boleano.
Nesse caso, podemos usar: “Yes”,1,”On” para habilitar ou “No”,0 or “Off” para desativar.
Vamos criar ele dentro do nosso diretório de configuração:
[plain]
cd /etc/pure-ftpd/conf
cat Yes > ChrootEveryone
ls -l
total 40
-rw-r–r– 1 root root 36 Feb 25 2015 AltLog
-rw-r–r– 1 root root 4 Mar 31 10:46 ChrootEveryone
-rw-r–r– 1 root root 6 Feb 25 2015 FSCharset
-rw-r–r– 1 root root 5 Feb 25 2015 MinUID
-rw-r–r– 1 root root 29 Feb 25 2015 MySQLConfigFile
-rw-r–r– 1 root root 4 Feb 25 2015 NoAnonymous
-rw-r–r– 1 root root 4 Feb 25 2015 PAMAuthentication
-rw-r–r– 1 root root 28 Feb 25 2015 PureDB
-rw-r–r– 1 root root 18 Feb 25 2015 TLSCipherSuite
-rw-r–r– 1 root root 3 Feb 25 2015 UnixAuthentication
[/plain]
Pronto, fazemos um “restart” no serviço e vamos testar:
[plain]
# systemctl restart pure-ftpd-mysql
:~# ftp servidor
Connected to servidor.
220———- Welcome to Pure-FTPd [privsep] [TLS] ———-
220-You are user number 1 of 50 allowed.
220-Local time is now 10:46. Server port: 21.
220-This is a private system – No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name (servidor:user): usuario
331 User usuario OK. Password required
Password:
230 OK. Current restricted directory is /
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> pwd
257 "/" is your current location
quit
[/plain]
Ok, agora o usuário vai ficar limitado ao diretório específico configurado para ele.

Comentários
Tão vazio aqui... deixe um comentário!