vsftpd: Installation und Konfiguration

Der folgende Artikel beschreibt die Installation des FTP-Servers vsftpd, die Konfiguration des Servers und das Starten des Dienstes über den TCP-Wrapper xinetd auf einem Linux Debian 5 (Lenny) System.

Installation:

# aptitude update
# aptitude install vsftpd
...
Starting FTP server: vsftpd.
Paketlisten werden gelesen... Fertig             
Abhängigkeitsbaum wird aufgebaut       
Lese Status-Informationen ein... Fertig
Lese erweiterte Statusinformationen      
Initialisiere Paketstatus... Fertig
Schreibe erweiterte Statusinformationen... Fertig
Lese Task-Beschreibungen... Fertig

Falls noch nicht auf dem System vorhanden, muss der TCP-Wrapper xinetd noch installiert werden:

vmdebian3:/etc# aptitude install xinetd
...

Für den FTP-Server vsftpd muss noch ein Startskript in /etc/xinetd.d angelegt werden:

/etc/xinetd.d/vsftpd

# default: on
# description:
# The vsftpTP server serves FTP connections. It uses
# normal, unencrypted usernames and passwords for authentication.
# vsftpd is designed to be secure.
service ftp
{
        socket_type             = stream
        wait                    = no
        user                    = root
        server                  = /usr/sbin/vsftpd
#       server_args             =
#       log_on_success          += DURATION USERID
#       log_on_failure          += USERID
        nice                    = 10
        disable                 = no
}

Reload xinetd um die Konfiguration neu einzulesen:

# /etc/init.d/xinetd reload
Reloading internet superserver configuration: xinetd.

Falls noch nicht verhanden, legen Sie Die Datei /etc/vsftpd.user_list an und fügen Sie eine Liste der User ein, denen der Login via FTP verboten werden soll. IdR sind das Systembenutzer, die vom System oder bestimmten Anwendungen erzeugt werden und nichts auf einem FTP Server verloren haben. Auch der Superuser root sollte aus Sicherheitsgründen in dieser Liste nicht fehlen.

/etc/vsftpd.user_list

# ftpusers      This file describes the names of the users that may
#               _*NOT*_ log into the system via the FTP server.
#               This usually includes "root", "uucp", "news" and the
#               like, because those users have too much power to be
#               allowed to do "just" FTP...
#
adabas
amanda
at
bin
cyrus
daemon
dbmaker
db2fenc1
db2inst1
db2as
db4web
dpbox
empress
fax
firewall
fnet
games
gdm
gnats
irc
informix
ingres
ixess
lnx
lp
mail
man
mdom
mysql
named
news
nobody
nps
oracle
perforce
pop
postfix
postgres
root
sapdb
skyrix
squid

Konfiguration:

Das zentrale Konfigurationsdatei des vsftpd ist /etc/vsftpd.conf. Hier eine Beispiel Konfiguration:

/etc/vsftpd.conf

# Run standalone?  vsftpd can run either from an inetd or as a standalone
# daemon started from an initscript.
# Diese Option muss auf NO gestellt sein, damit vsftpd nicht schon beim Systemstart
# gestartet wird, sondern durch den xinetd gestartet wird
#
listen=NO
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
# Wir wollen keinen anonymen Login auf unserem Server:
#
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
# Wir legen unsere User die FTP nutzen dürfen selbst an:
#
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
#
local_umask=022
#
# Wir verbieten FTP Clients die Änderungen an Dateiberechtigungen und erzwingen
# dadurch die og umask:
#
chmod_enable=NO
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
xferlog_file=/var/log/vsftpd.log
#
# You may fully customise the login banner string:
ftpd_banner=Welcome to prontosystems.org  FTP service.
#
# You may restrict local users to their home directories.  See the FAQ for
# the possible risks in this before using chroot_local_user or
# chroot_list_enable below.
chroot_local_user=YES
#
# This option should be the name of a directory which is empty.  Also, the
# directory should not be writable by the ftp user. This directory is used
# as a secure chroot() jail at times vsftpd does not require filesystem
# access.
#
secure_chroot_dir=/var/run/vsftpd
#
# This string is the name of the PAM service vsftpd will use.
#
pam_service_name=vsftpd
#
# This option specifies the location of the RSA certificate to use for SSL
# encrypted connections.
rsa_cert_file=/etc/ssl/certs/vsftpd.pem
#
# Maximale Anzahl von Anmeldeversuchen pro Session. Diese Angabe ist wichtig, wenn
# der FTP Login von einem Script überwacht wird, welches nach einer bestimmten Anzahl
# fehlgeschlagener Anmeldeversuche, den Zugang blockiert. Das funktioniert nur dann,
# wenn der Zugang unterbrochen wird. Ohne diese Option würde die Session so lange
# offen bleiben, wie der Brute Force Versuch andauert.
#
max_login_fails=3
#
# Delay in Sekunden zwischen erneutem Anmeldeversuch:
#
delay_failed_login=5
#
# The userlist_enable" option instructs vsftpd to either consult or not consult either of 2 files: 
#vsftpd.ftpusers and vsftpd.user_list. If this option is set to "YES", the 2 files serve as lists 
#of users that are allowed to FTP to the server. However, when coupled with the "userlist_deny=YES"" 
#option, the 2 files serve as list of users who are NOT allowed to FTP to the server. This option is 
#very useful in completely denying FTP access to critical system users such as "root" or "apache" or 
#"www". A very nice layer of security for your FTP server.
#
userlist_enable=YES
userlist_deny=YES
check_shell=NO

Weitere Information zu der Option max_login_fails finden Sie im Artikel -> BlockHosts
Der FTP-Server sollte nun fertig installiert und konfiguriert sein.

Testen der Installation / Konfiguration

Verifizieren das der FTP Server derzeit nicht läuft:

# ps -eaf| grep vsftp | grep -v grep 
#

Anmelden vom lokalen Host an den FTP Server:

# ftp localhost
Connected to localhost.
220 Welcome to prontosystems.org  FTP service.
Name (localhost:pronto): pronto
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.ftp> ls -la
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
drwxr-xr-x    4 1000     1000         4096 Apr 24 20:27 .
drwxr-xr-x    4 1000     1000         4096 Apr 24 20:27 ..
drwx------    2 1000     1000         4096 Apr 24 19:40 .aptitude
-rw-------    1 1000     1000           62 Apr 24 20:27 .bash_history
-rw-r--r--    1 1000     1000          220 Nov 24 20:32 .bash_logout
-rw-r--r--    1 1000     1000         3116 Nov 24 20:32 .bashrc
drwxr-xr-x    2 1000     1000         4096 Apr 24 19:40 .debtags
-rw-r--r--    1 1000     1000          675 Nov 24 20:32 .profile
226 Directory send OK.
ftp> bye
221 Goodbye.

Wuppt!!!

Verwandte Artikel:
-> Serverdienst Zugangskontrolle
-> FTP Session automatisieren
-> Aktives und passives FTP
-> E-Mail vs FTP
-> »/bin/false« als Login Shell für FTP User konfigurieren

pronto 2010/04/24 23:38

tux/vsftpd.txt (20861 views) · Zuletzt geändert: 2011/04/18 01:45 von wikisysop
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0