In questa guida, vedremo come configurare un server FTP (ProFTPd) per trasferire file tra il tuo PC e il tuo server.
Prerequisiti
- Un'istanza del server Vultr CentOS appena distribuita.
- Un utente Sudo .
Installazione
Aggiorna il sistema.
yum check-update
I repository RHEL / CentOS 6/7 ufficiali non forniscono alcun pacchetto binario per il server ProFTPD, quindi è necessario aggiungere repository di pacchetti extra sul sistema forniti dal repository EPEL 6/7 utilizzando uno dei seguenti comandi.
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
Scarica tutti i metadati per i repository yum attualmente abilitati.
sudo yum makecache
Installa proftpd
.
sudo yum install proftpd
Installa ftp
.
sudo yum install ftp
Configurazione
Apri il file di configurazione ProFTPd.
sudo nano /etc/proftpd.conf
Il file sarà simile al seguente testo.
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
...
Principali direttive di configurazione
ServerName
: Specifica il nome del server FTP. Questo nome verrà visualizzato quando i client si connettono al server.
DefaultRoot
: Controlla la directory principale predefinita assegnata a un utente al momento dell'accesso.
MaxInstances
: Il numero massimo di connessioni simultanee che si desidera consentire sul proprio server FTP.
Ora, dobbiamo cambiare il ServerName
.
ServerName : the name of your FTP server
Nota : per impostazione predefinita, qualcuno che si connette al server FTP può accedere a tutte le cartelle del server, quindi si consiglia di abilitare l'opzioneDefaultRoot
.
DefaultRoot ~ !adm
Dopo aver modificato la configurazione, riavviare il server.
sudo service proftpd restart
Nota : se una riga di errore viene visualizzata come " unable to resolve host
", tenere presente che non ha importanza e che è possibile ignorarla.
Aggiungi un utente FTP
Aggiungi un utente.
useradd --shell /bin/false myuser
Crea la home directory del nostro utente " myuser
".
mkdir /home/myuser
Cambia la proprietà di quella directory per l'utente e il gruppo " myuser
".
chown myuser:myuser /home/myuser/
Imposta una password per l'utente " myuser
".
passwd myuser
Connettiti al tuo server FTP
Ora che il tuo server FTP è installato e configurato, ti piacerebbe essere in grado di connettersi ad esso.
Digita semplicemente ftp://server_ip_address
la barra degli indirizzi del tuo browser. Sostituisci server_ip_address
con l'indirizzo IP del tuo server. Ti verrà chiesto il tuo username
e password
.
Puoi vedere chi è connesso al tuo server FTP con il seguente comando.
ftpwho
Puoi anche vedere le statistiche.
ftpstats