Sto eseguendo vsftpd come server ftp sul mio linux (rasbian), accedo alla macchina come utente root.
Vorrei essere ancora bloccato sull'utilizzo solo di /var/www, come posso configurare vsftpd conf per farlo?
Risposta accettata:
Metodo 1:modifica della home directory dell'utente
Assicurati che la riga seguente esista
chroot_local_user=YES
Imposta la directory HOME dell'utente su /var/www/
, se desideri modificare l'utente esistente, puoi utilizzare:
usermod --home /var/www/ username
quindi imposta l'autorizzazione richiesta su /var/www/
Metodo 2:usa user_sub_token
Se non desideri modificare la directory Home dell'utente, puoi utilizzare:
chroot_local_user=YES
local_root=/ftphome/$USER
user_sub_token=$USER
Informazioni su user_sub_token
:
Genera automaticamente una home directory per ogni utente virtuale, in base a un modello.
Ad esempio, se la home directory dell'utente reale specificato tramite guest_username è
/ftphome/$USER e user_sub_token è impostato su $ USER, quindi quando l'utente virtuale test
accede, finirà (di solito chroot()'ed) nella directory /ftphome/test.
Questa opzione ha effetto anche se root_locale contiene user_sub_token.
Crea directory e imposta i permessi:
mkdir -p /ftphome/{test,user1,user2}
chmod 770 -R /ftphome
chown -R ftp. /ftphome
usermod -G ftp test
Una volta riavviato vsftpd
e prova la tua configurazione.
Esempio di output di successo:
[[email protected] tmp]# ftp localhost
Connected to mail.linuxian.local.
220 (vsFTPd 2.0.5)
530 Please login with USER and PASS.
530 Please login with USER and PASS.
KERBEROS_V4 rejected as an authentication type
Name (localhost:root): test
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> mput vhosts
mput vhosts?
227 Entering Passive Mode (127,0,0,1,146,41)
150 Ok to send data.
226 File receive OK.
24 bytes sent in 3.3e-05 seconds (7.1e+02 Kbytes/s)
ftp> ls -rlt
227 Entering Passive Mode (127,0,0,1,97,90)
150 Here comes the directory listing.
-rw-r--r-- 1 787 787 24 Oct 11 19:57 vhosts
226 Directory send OK.
ftp> 221 Goodbye.