Configuration of FTP Server

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 5

Configuration of ftp server

How To Get VSFTPD Started:


You can start, stop, or restart VSFTPD after booting by using these commands:

[root@bigboy tmp]# service vsftpd start


[root@bigboy tmp]# service vsftpd stop
[root@bigboy tmp]# service vsftpd restart

To configure VSFTPD to start at boot you can use the chkconfig command.
[root@bigboy tmp]# chkconfig vsftpd on

Note: In RedHat Linux version 8.0 and earlier, VSFTPD operation is controlled by the xinetd process, which
is covered in Chapter 16, "TELNET, TFTP, and XINETD." You can find a full description of how to configure
these versions of Linux for VSFTPD in Appendix III, "Fedora Version Differences."

Testing the Status of VSFTPD:


You can always test whether the VSFTPD process is running by using the netstat -a command which lists all
the TCP and UDP ports on which the server is listening for traffic. This example shows the expected output.

[root@bigboy root]# netstat -a | grep ftp


tcp 0 0 *:ftp *:* LISTEN
[root@bigboy root]#

If VSFTPD wasn't running, there would be no output at all.

The vsftpd.conf File:


VSFTPD only reads the contents of its vsftpd.conf configuration file only when it starts, so you'll have to
restart VSFTPD each time you edit the file in order for the changes to take effect.
This file uses a number of default settings you need to know about.
> VSFTPD runs as an anonymous FTP server. Unless you want any remote user to log into to your default
FTP directory using a username of anonymous and a password that's the same as their email address, I
would suggest turning this off. The configuration file's anonymous_enable directive can be set to no to
disable this feature. You'll also need to simultaneously enable local users to be able to log in by removing
the comment symbol (#) before the local_enable instruction.
> VSFTPD allows only anonymous FTP downloads to remote users, not uploads from them. This can be
changed by modifying the anon_upload_enable directive shown later.
> VSFTPD doesn't allow anonymous users to create directories on your FTP server. You can change this
by modifying the anon_mkdir_write_enable directive.
> VSFTPD logs FTP access to the /var/log/vsftpd.log log file. You can change this by modifying the
xferlog_file directive.
> By default VSFTPD expects files for anonymous FTP to be placed in the /var/ftp directory. You can
change this by modifying the anon_root directive. There is always the risk with anonymous FTP that users
will discover a way to write files to your anonymous FTP directory. You run the risk of filling up your /var
partition if you use the default setting. It is best to make the anonymous FTP directory reside in its own
dedicated partition.

The configuration file is fairly straight forward as you can see in the snippet below.
# Allow anonymous FTP?
anonymous_enable=YES
...
# Uncomment this to allow local users to log in.
local_enable=YES
...
# Uncomment this to enable any form of FTP write command.
# (Needed even if you want local users to be able to upload files)
write_enable=YES
...
# Uncomment to allow the anonymous FTP user to upload files. This only
# has an effect if global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
...
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
...
# Activate logging of uploads/downloads.
xferlog_enable=YES
...
# You may override where the log file goes if you like.
# The default is shown# below.
#xferlog_file=/var/log/vsftpd.log
...
# The directory which vsftpd will try to change
# into after an anonymous login. (Default = /var/ftp)
#anon_root=/data/directory

To activate or deactivate a feature, remove or add the # at the beginning of the appropriate line.
Other vsftpd.conf Options
There are many other options you can add to this file:
o Limiting the maximum number of client connections (max_clients)
o Limiting the number of connections by source IP address (max_per_ip)
o The maximum rate of data transfer per anonymous login. (anon_max_rate)
o The maximum rate of data transfer per non-anonymous login. (local_max_rate)
Descriptions on this and more can be found in the vsftpd.conf man pages.

FTP Security Issues:


FTP has a number of security drawbacks, but you can overcome them in some cases. You can restrict an
individual Linux user's access to non-anonymous FTP, and you can change the configuration to not display
the FTP server's software version information, but unfortunately, though very convenient, FTP logins and
data transfers are not encrypted.
The /etc/vsftpd.ftpusers File
For added security, you may restrict FTP access to certain users by adding them to the list of users in
the /etc/vsftpd.ftpusers file. The VSFTPD package creates this file with a number of entries for privileged
users that normally shouldn't have FTP access. As FTP doesn't encrypt passwords, thereby increasing the
risk of data or passwords being compromised, it is a good idea to let these entries remain and add new
entries for additional security.

Anonymous Upload
If you want remote users to write data to your FTP server, then you should create a write-only directory
within /var/ftp/pub. This will allow your users to upload but not access other files uploaded by other users.
The commands you need are:

[root@bigboy tmp]# mkdir /var/ftp/pub/upload


[root@bigboy tmp]# chmod 722 /var/ftp/pub/upload

FTP Greeting Banner


Change the default greeting banner in the vsftpd.conf file to make it harder for malicious users to
determine the type of system you have. The directive in this file is.

ftpd_banner= New Banner Here


Using SCP As Secure Alternative To FTP
One of the disadvantages of FTP is that it does not encrypt your username and password. This could make
your user account vulnerable to an unauthorized attack from a person eavesdropping on the network
connection. Secure Copy (SCP) and Secure FTP (SFTP) provide encryption and could be considered as an
alternative to FTP for trusted users. SCP does not support anonymous services, however, a feature that
FTP does support.

Tutorial:
FTP has many uses, one of which is allowing numerous unknown users to download files. You have to be
careful, because you run the risk of accidentally allowing unknown persons to upload files to your server. This
sort of unintended activity can quickly fill up your hard drive with illegal software, images, and music for the
world to download, which in turn can clog your server's Internet access and drive up your bandwidth charges.
FTP Users with Only Read Access to a Shared Directory
In this example, anonymous FTP is not desired, but a group of trusted users need to have read only access
to a directory for downloading files. Here are the steps:

1. Disable anonymous FTP. Comment out the anonymous_enable line in the vsftpd.conf file like this:

# Allow anonymous FTP?


# anonymous_enable=YES
2. Enable individual logins by making sure you have the local_enable line uncommented in the
vsftpd.conf file like this:

# Uncomment this to allow local users to log in.


local_enable=YES
3. Start VSFTP.

[root@bigboy tmp]# service vsftpd start

4. Create a user group and shared directory. In this case, use /home/ftp-users and a user group name of
ftp-users for the remote users

[root@bigboy tmp]# groupadd ftp-users


[root@bigboy tmp]# mkdir /home/ftp-docs

5. Make the directory accessible to the ftp-users group.

[root@bigboy tmp]# chmod 750 /home/ftp-docs


[root@bigboy tmp]# chown root:ftp-users /home/ftp-docs

6. Add users, and make their default directory /home/ftp-docs


[root@bigboy tmp]# useradd -g ftp-users -d /home/ftp-docs user1
[root@bigboy tmp]# useradd -g ftp-users -d /home/ftp-docs user2
[root@bigboy tmp]# useradd -g ftp-users -d /home/ftp-docs user3
[root@bigboy tmp]# useradd -g ftp-users -d /home/ftp-docs user4
[root@bigboy tmp]# passwd user1
[root@bigboy tmp]# passwd user2
[root@bigboy tmp]# passwd user3
[root@bigboy tmp]# passwd user4

7. Copy files to be downloaded by your users into the /home/ftp-docs directory

8. Change the permissions of the files in the /home/ftp-docs directory for read only access by the group

[root@bigboy tmp]# chown root:ftp-users /home/ftp-docs/*


[root@bigboy tmp]# chmod 740 /home/ftp-docs/*

Users should now be able to log in via FTP to the server using their new usernames and passwords. If
you absolutely don't want any FTP users to be able to write to any directory, then you should set the
write_enable line in your vsftpd.conf file to no:

write_enable = NO

Remember, you must restart VSFTPD for the configuration file changes to take effect.

10. Connect to bigboy via FTP


[root@smallfry tmp]# ftp 192.168.3.40 (ip address of the host)
you will get a prompt like
ftp>

FTP commands and files:


/etc/ftpaccess : General configuration file: classes of users, access definitions, logging, etc.
Example:
class all real,guest,anonymous *
limit all 10 Any /etc/msgs/msg.dead
readme README* login
readme README* cwd=*
message /welcome.msg login
message .message cwd=*
compress yes all
tar yes all
log commands real
log transfers anonymous,real inbound,outbound
shutdown /etc/shutmsg
email user@hostname

/etc/ftphosts : Individual user host access to allow / deny a given username from an address.
# Example host access file
# Everything after a '#' is treated as comment,
# empty lines are ignored

allow bartm somehost.domain


deny fred otherhost.domain 131.211.32.*

/etc/ftpgroups : It allow us to set up groups of users.

/etc/ftpusers : Users who are not allowed to log in.

/etc/ftpconversions : Allows users to request specific on-the-fly conversions.

 chroot - Run with a special root directory


 ftpcount - Show number of concurrent users.
 ftpshut - close down the ftp servers at a given time
 ftprestart - Restart previously shutdown ftp servers
 ftpwho - show current process information for each ftp user

Commands that will help in uploading and downloading files:

To download files
ftp> get remote-file-name local-file-name
ftp> mget remote-file-name1 remote-file-name2………………….

To upload files
ftp> put local-file-name remote-file-name

please check the man pages of put, get and mget.


By default the file transfer mode using ftp is binary. To change the mode of transfer use the command
ascii.

ftp> ascii

You might also like