Monday, November 28, 2011

FTP Server Configuration

Introduction:-
FTP is File Transfer Protocol which is used to transfer files between server and clients. FTP is most used protocol over internet to transfer files and it support all the platforms. FTP server works on client-server architecture. FTP client can easily connect to FTP server and it can download and upload files.
Requirement:-
  • Package = vsftpd
  • Port = 20 [ Control Connection ]
                      21 [ Data Control ]
  • Configuration File = /etc/vsftpd/vsftpd.conf
  • Service = vsftpd
  • FTP home dirctory = pub
Per quest on FTP Server:-
  • Configure FTP Server IP = 192.168.1.1
  • Configure Linux Client IP = 192.168.1.2
  • Configure Windows Client IP = 192.168.1.3
  • Hostname = server.rootuser.in
  • Firewall must be disabled of Server and Client
FTP Server Side Configuration:-
1] Install vsftpd package for FTP service
[root@server ~]# yum install vsftpd* -y
2] Verify wheather the package is install or not
[root@server ~]# rpm -qa vsftpd
3] Edit main configuration file of FTP service. ( Uncomment the follwoing lines which are in BOLD format)
[root@server ~]# vim /etc/vsftpd/vsftpd.conf
#Allow anonymous user to get login to FTP   anonymous_enable=YES
#To allow local users to log in uncommnet this line. 
local_enable = YES
#Uncomment this line if you want local users to be able to upload files.
write_enable = YES
#To allow uploading for anonymous user uncomment this line.
anon_upload_enable=YES
#To activate loging of uploading and downloading.
xferlog_enbable = YES
#The log file of FTP are default store location is; you may change this location
xferlog_file=/var/log/vsftpd.log
#You may change the default value for timing out an idle session.
idle_session_timeout=1200
# You may for some reason decide to limit that amount of users that connect to your
servers at any time, and how many simultaneous connections can be maintained from
each ip address then add following line to the end of file: 
max_clients=20
max_per_ip=4
:wq

4] Create the resources that are downloaded by anonymous user, and create upload 
directory to store uploaded files of public user.
[root@server ~]# cd /var/ftp/pub
[root@server pub]# touch anup1 anup2 anup3 anup4 anup5
[root@server pub]# ls
[root@server pub]# cd ..
[root@server ftp]# mkdir upload
[root@server ftp]# cd
5] Create one local user to get login to FTP service from client side.
[root@server ~]# useradd anup
[root@server ~]# passwd anup  
6] Set Selinux security related options.
[root@server ~]# getsebool -a | grep ftp
[root@server ~]# setsebool allow_ftpd_full_access on
[root@server ~]# setsebool ftp_home_dir on
[root@server ~]# getsebool -a | grep ftp  
7] Finally start vsftpd service and make it permanent at next reboot
[root@server ~]# service vsftpd start
[root@server ~]# chkconfig vsftpd on    
FTP Client Side Configuration
1] Check communication wih FTP Server
[root@client ~}# ping 192.168.1.1
2] Create some files to upload.
[root@client ~}# mkdir data
[root@client ~}# cd data
[root@client data]# touch file1 file2 file3 file4
[root@client data]# cd  
3] Now try to connect with anonymous user and password is blan (just press enter).
[root@client data]# ftp 192.168.1.1
Username : anonymous
password : <┘(press enter)
Log in successful.
ftp> ls
ftp> cd pub
ftp> get anup1 # To download single file.
ftp> get anup* # To download multiple file.
ftp> cd ..
ftp> cd upload
ftp> put file1 # To upload single file.
ftp> put file* # To upload multiple file.
ftp> bye
[root@client data]# ls
[ Note = Go to FTP server machine and verify the file which are uploaded under /var/ftp/upload ]  
4] You can also connect to FTP with local user which we have created initally. ( i.e. Anup )
[ Note = Local user must connect to it's home directory on server ]
[anup@client ~]$ ftp 192.168.1.1
Username : anup
password : anup
Login Successful.
ftp> bye

2 comments:

Jefferson Aquino said...

Hi Sir,

This really help me alot.

Two thumbs for you!!!

Thank you.

Delco said...

yes thanks for sharing