Il problema
Accedi al server vsftp con utente anonimo dal client ftp, prova a caricare un file non riesce con messaggio di errore:
# ftp vsftpsrv Connected to vsftpsrv (10.182.38.176). 220 (vsFTPd 2.0.5) Name (10.182.38.176:root): anonymous 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> pwd 257 "/" ftp> ls 227 Entering Passive Mode (10,182,38,176,29,34) 150 Here comes the directory listing. drwxr-xr-x 2 0 0 4096 Jan 09 2013 pub 226 Directory send OK. ftp> put vsftpd.txt mput vsftpd.txt? y 227 Entering Passive Mode (10,182,38,176,182,24) 550 Permission denied. ftp>
La soluzione
Per impostazione predefinita, l'utente anonimo non può caricare file né creare una directory sul server vsftp con restrizioni nel file di configurazione.
Nota :l'utente anonimo non può caricare il file nella directory vsftpd "/", creare prima una sottodirectory come soluzione alternativa.1. Sul server vsftp, assicurati che la riga sottostante esista e non sia commentata in /etc/vsftpd/vsftpd.conf :
anon_upload_enable=YESNota :se consenti a un utente anonimo di creare una directory, decommenta anche “anon_mkdir_write_enable=YES”.
2. Sul server vsftp, creare una sottodirectory nella directory vsftpd "/" /var/ftp/
# mkdir /var/ftp/anon_upload
3. Quindi cambia la proprietà della directory in ftp:root e il permesso in 0777:
# chown ftp:root /var/ftp/anon_upload/ # chmod 0777 /var/ftp/anon_upload/ # stat /var/ftp/anon_upload/ File: `/var/ftp/anon_upload/' Size: 4096 Blocks: 8 IO Block: 4096 directory Device: fc00h/64512d Inode: 719500 Links: 2 Access: (0777/drwxrwxrwx) Uid: ( 14/ ftp) Gid: ( 0/ root) Access: 2014-02-25 09:27:47.000000000 -0500 Modify: 2014-02-25 09:26:04.000000000 -0500 Change: 2014-02-25 09:38:17.000000000 -0500
4. Riavvia il servizio vsftpd sul server vsftp:
# service vsftpd restart Shutting down vsftpd: [ OK ] Starting vsftpd for vsftpd: [ OK ]
5. Accedi al server vsftp dal client ftp, carica il file nella nuova directory creata:
# ftp vsftpsrv Connected to vsftpsrv (10.182.38.176). 220 (vsFTPd 2.0.5) Name (10.182.38.176:root): anonymous 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> pwd 257 "/" ftp> ls 227 Entering Passive Mode (10,182,38,176,205,23) 150 Here comes the directory listing. drwxrwxrwx 2 14 0 4096 Feb 25 14:26 anon_upload drwxr-xr-x 2 0 0 4096 Jan 09 2013 pub 226 Directory send OK. ftp> cd anon_upload 250 Directory successfully changed. ftp> put vsftpd.txt local: vsftpd.txt remote: vsftpd.txt 227 Entering Passive Mode (10,182,38,176,34,113) 150 Ok to send data. 226 File receive OK. 38 bytes sent in 1.3e-05 secs (2923.08 Kbytes/sec) ftp> ls 227 Entering Passive Mode (10,182,38,176,124,56) 150 Here comes the directory listing. -rw------- 1 14 50 38 Feb 25 14:39 vsftpd.txt 226 Directory send OK. ftp>
Errori comuni:
1. Se il passaggio della soluzione 3 sopra non è impostato, il file di caricamento con l'utente anonimo incontrerà il seguente errore:
# ftp vsftpsrv Connected to vsftpsrv (10.182.38.176). 220 (vsFTPd 2.0.5) Name (10.182.38.176:root): anonymous 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> pwd 257 "/" ftp> ls 227 Entering Passive Mode (10,182,38,176,159,123) 150 Here comes the directory listing. drwxr-xr-x 2 0 0 4096 Feb 25 14:26 anon_upload drwxr-xr-x 2 0 0 4096 Jan 09 2013 pub 226 Directory send OK. ftp> cd anon_upload 250 Directory successfully changed. ftp> pwd 257 "/anon_upload" ftp> put vsftpd.txt local: vsftpd.txt remote: vsftpd.txt 227 Entering Passive Mode (10,182,38,176,179,248) 553 Could not create file. ftp>
2. Se concedi la directory vsftpd "/" con l'autorizzazione 0775:"# chmod -R 0775 /var/ftp", l'accesso dell'utente anonimo fallirà per motivi di sicurezza:
# ftp vsftpsrv Connected to vsftpsrv (10.182.38.176). 220 (vsFTPd 2.0.5) Name (10.182.38.176:root): anonymous 331 Please specify the password. Password: 500 OOPS: vsftpd: refusing to run with writable anonymous root Login failed. ftp>