Erfahren Sie, wie Sie einschränken oder begrenzen, welche FTP-Befehle Benutzer auf vsftpd-Diensten ausführen können. Zum Beispiel, wie man einem Benutzer verweigert, ein Verzeichnis zu erstellen oder zu entfernen.
1. Die vsftpd-Dienste werden installiert und mit Standardoptionen konfiguriert. Das Anlegen und Löschen von Verzeichnissen funktioniert wie erwartet.
# ftp localhost Trying 127.0.0.1... Connected to localhost (127.0.0.1). 220 (vsFTPd 3.0.2) 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>ftp> mkdir test 257 "/home/test/test" created
ftp> rmdir test 250 Remove directory operation successful. ftp>
2. Dem Benutzer wurde das Erstellen oder Entfernen eines Verzeichnisses verweigert. Fügen Sie die folgenden Zeilen am Ende der Datei /etc/vsftpd/vsftpd.conf hinzu .
# tail /etc/vsftpd/vsftpd.conf tcp_wrappers=YES # Allowed commands #cmds_allowed=ABOR,ACCT,ALLO,APPE,CDUP,CWD,DELE,EPRT,EPSV,FEAT,HELP,LIST,MDTM,MODE,NLST,NOOP,OPTS,PASS,PASV,PORT,PWD,QUIT,REIN,REST,RETR,RMD,RNFR,RNTO,SITE,SIZE,SMNT,STAT,STOR,STOU,STRU,SYST,TYPE,USER,XCUP,XCWD,XPWD,XRMD # Explicitly denied commands cmds_denied=RMD,RMDIR,XRMD,MKD,MKDIR,XMKD
3. Starten Sie den vsftpd-Dienst neu
# systemctl restart vsftpd
Hinweis:Verwenden Sie für Oracle Linux 6
# service vsftpd restart
4. Der Benutzer kann ein Verzeichnis nicht erstellen oder entfernen:
# ftp localhost Trying 127.0.0.1... Connected to localhost (127.0.0.1). 220 (vsFTPd 3.0.2) 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> ftp> mkdir test2 550 Permission denied. ftp> ftp> rmdir test 550 Permission denied. ftp>
Weitere Informationen finden Sie in den Manpages:
# man vsftpd.conf cmds_allowed This option specifies a comma-separated list of allowed FTP commands (post login. USER, PASS and QUIT and others are always allowed pre-login). Other commands are rejected. This is a powerful method of really locking down an FTP server. Example: cmds_allowed=PASV,RETR,QUIT Default: (none) cmds_denied This option specifies a comma-separated list of denied FTP commands (post login. USER, PASS, QUIT and others are always allowed pre-login). If a command appears on both this and cmds_allowed then the denial takes precedence. (Added in v2.1.0).