FTP Server - Red Hat Linux
FTP in Linux
Introduction to FTP
The File Transfer Protocol (FTP) is used as one of the most common means of copying files between servers over the Internet.
Regular FTP
The VSFTP allows Linux users to copy files to and from their home directories with an FTP client.
Anonymous FTP
Anonymous FTP a username of ‘anonymous’ and your email address for the password.
Once logged in to a FTP server, you automatically have access to only the default anonymous FTP directory
FTP Overview
FTP relies on a pair of TCP ports to get the job done. It operates in two connection channels as I'll explain:
FTP Control Channel, TCP Port 21: All commands you send and the ftp server's responses to those commands will go over the control connection, but any data sent back (such as "ls" directory lists or actual file data in either direction) will go over the data connection.
FTP Data Channel, TCP Port 20: This port is used for all subsequent data transfers between the client and server.
In addition to these channels, there are several varieties of FTP.
Types of FTP
From a networking perspective, the two main types of FTP are active and passive. In active FTP, the FTP server initiates a data transfer connection back to the client. For passive FTP, the connection is initiated from the FTP client
1. Active FTP
2. Passive FTP
Start VSFTP
Use the ‘chkconfig’ command to configure VSFTP to start at boot:
chkconfig vsftpd on
Use ‘service vsftpd’ to start,stop, and restart VSFTP after booting:
service vsftpd start
service vsftpd stop
service vsftpd restart \
Configuration file: /etc/vsftpd/vsftpd.conf
Anonymous FTP settings
Before going to change vsftpd.conf, remember to make a backup:
cp vsftpd.conf vsftpd.conf.bak
anonymous_enable=YES
Allow Anonymous
anon_upload_enable=YES
Allow Anonymous upload
anon_mkdir_write_enable=YES
Allow Anonymous upload to create directory
no_anon_password=YES
Do not ask password for anonymous login
anon_max_rate=30000
Limit the transfer rate of anonymous, e.g. 30000 = 30k byte per second
anon_root=/data/directory
Directory for anonymous is ‘/var/ftp’
Local users’ settings
local_enable=YES
Allow Linux users to use VSFTPD
chroot_list_enable=YES
VSFTPD will use a file to limit some users to change their home directories after login
chroot_list_file=/etc/vsftpd/chroot_list
A text file which contain a list of Linux usernames.
These users will limit to their home directories
userlist_deny=YES
VSFTPD will use a file to reject some users.
userlist_file=/etc/vsftpd/user_list
A text file which contain a list of Linux usernames which DO NOT allow to use VSFTP.
local_max_rate=30000
Limit the transfer rate of local user, e.g. 30000 = 30k byte per second
Other Settings
Limiting the maximum number of client connections
max_per_ip=1
Limiting the number of connections by same IP address
idle_session_timeout=600
Disconnect the idle connection after 600 seconds.
xferlog_enable=YES
Record all the file transfer records.
xferlog_file=/var/log/vsftpd.log
Filename and directory of log file.
Limit the access on hosts
FTP server usually can use tcp_wrappers to allow or deny a host’s access.
Add this statement to vsftpd.conf:
tcp_wrappers = yes
Under /etc, create a new file hosts.deny:
vsftpd : 192.168.1.0/24 192.168.0.2
vsftpd : .vtc.edu.hk alan.ict.edu.hk
If you want to allow a specific host, create a hosts.allow with same format.
Power of hosts.allow > hosts.deny
Step by step
1. Package Name: vsftpd2. Document Root: /var/ftp/pub/
3. Configuration File: /etc/vsftpd/vsftpd.conf
4. Comds To Be Exec on Terminal:
a. #yum install vsftpd* -y
b. #service vsftpd restart;
# chkconfig vsftpd on
[N.B. At this stage any existing user can access the ftp from their browser using the ftp host IP e,g ftp://192.168.0.1.They can download anything that is placed inside the document root /var/ftp/pub.To restrict ftp use follow the steps mentioned below.]
c.
#vim /etc/vsftpd/vsftpd.conf
Edit following fields:
Anonymous_enable=NO
Chroot_list_enable=YES
Save and exit the configuration file.
d.
#service vsftpd restart;
#chkconfig vsftpd on
No comments