Requisits previs
Instal·lació
Afegeix un usuari FTP
Connecteu-vos al vostre servidor FTP
En aquesta guia, veurem com configurar un servidor FTP (ProFTPd) per transferir fitxers entre el vostre PC i el vostre servidor.
Requisits previs
- Una instància de servidor Vultr CentOS recentment desplegada.
- Un usuari de Sudo .
Instal·lació
Actualitzar el sistema.
yum check-update
Els dipòsits oficials de RHEL/CentOS 6/7 no proporcionen cap paquet binari per al servidor ProFTPD, de manera que cal que afegiu dipòsits de paquets addicionals al vostre sistema proporcionats per EPEL 6/7 repo mitjançant una de les ordres següents.
CentOS 6 :
sudo rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
CentOS 7 :
sudo rpm -Uvh http://ftp.astral.ro/mirrors/fedora/pub/epel/beta/7/x86_64/epel-release-7-0.2.noarch.rpm
Baixeu totes les metadades dels repositoris yum activats actualment.
sudo yum makecache
Instal·lar proftpd.
sudo yum install proftpd
Instal·lar ftp.
sudo yum install ftp
Configuració
Obriu el fitxer de configuració de ProFTPd.
sudo nano /etc/proftpd.conf
El fitxer s'assemblarà al text següent.
The file will resemble the following text.
# This is the ProFTPD configuration file
#
# See: http://www.proftpd.org/docs/directives/linked/by-name.html
# Server Config - config used for anything outside a <VirtualHost> or <Global> $
# See: http://www.proftpd.org/docs/howto/Vhost.html
ServerName "ProFTPD server"
ServerIdent on "FTP Server ready."
ServerAdmin root@localhost
DefaultServer on
# Cause every FTP user except adm to be chrooted into their home directory
# Aliasing /etc/security/pam_env.conf into the chroot allows pam_env to
# work at session-end time (http://bugzilla.redhat.com/477120)
VRootEngine on
DefaultRoot ~ !adm
VRootAlias /etc/security/pam_env.conf etc/security/pam_env$
# Use pam to authenticate (default) and be authoritative
AuthPAMConfig proftpd
AuthOrder mod_auth_pam.c* mod_auth_unix.c
# If you use NIS/YP/LDAP you may need to disable PersistentPasswd
#PersistentPasswd off
# Don't do reverse DNS lookups (hangs on DNS problems)
UseReverseDNS off
# Set the user and group that the server runs as
User nobody
Group nobody
# To prevent DoS attacks, set the maximum number of child processes
# to 20. If you need to allow more than 20 concurrent connections
# at once, simply increase this value. Note that this ONLY works
# in standalone mode; in inetd mode you should use an inetd server
# that allows you to limit maximum number of processes per service
# (such as xinetd)
MaxInstances 20
...
Principals directrius de configuració
ServerName: Especifica el nom del servidor FTP. Aquest nom es mostrarà quan els clients es connectin al servidor.
DefaultRoot: Controla el directori arrel predeterminat assignat a un usuari en iniciar sessió.
MaxInstances: el nombre màxim de connexions simultànies que voleu permetre al vostre servidor FTP.
Ara, hem de canviar el ServerName.
ServerName : the name of your FTP server
Nota : per defecte, algú que es connecti al servidor FTP pot accedir a totes les carpetes del servidor, per la qual cosa es recomana activar l'opcióDefaultRoot .
DefaultRoot ~ !adm
Després de canviar la configuració, reinicieu el servidor.
sudo service proftpd restart
Nota : si es mostra una línia d'error com a " unable to resolve host", tingueu en compte que no importa i podeu ignorar-la.
Afegeix un usuari FTP
Afegeix un usuari.
useradd --shell /bin/false myuser
Creeu el directori inicial del nostre usuari " myuser".
mkdir /home/myuser
Canvieu la propietat d'aquest directori a l'usuari i al grup " myuser".
chown myuser:myuser /home/myuser/
Establiu una contrasenya per a l'usuari " myuser".
passwd myuser
Connecteu-vos al vostre servidor FTP
Ara que el vostre servidor FTP està instal·lat i configurat, us agradaria poder connectar-hi.
Només has d'escriure ftp://server_ip_addressa la barra d'adreces del teu navegador. Substituïu server_ip_address-la per l'adreça IP del vostre servidor. Aleshores se us demanarà el vostre usernamei password.
Podeu veure qui està connectat al vostre servidor FTP amb l'ordre següent.
ftpwho
També podeu veure les estadístiques.
ftpstats