Friday, April 25, 2014

Configure and set up ftp

            FTP

- FTP stands for File transfer protocol
- It is used for uploading and downloading the files
- By Default, Root is not allowed for FTP service because,
  FTP sends and recievs in clear text form

- Package name     = vsftpd     [for Server]
- Package name     = ftp         [for Client]
- Port NO.    = 20 , 21
- Configuration file = /etc/vsftpd/vsftpd.conf
- Service     = vsftpd
- Default Enabled user = anonymous    // works without passowrd

-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------

FTP -        Server Side

# yum install vsftpd -y
# service vsftpd restart
# chkconf vsftpd on
# cd /var/ftp/pub
# touch a b c d e

-----------------------------------------------------------------------------------------

FTP -        Client Side

# yum install ftp -y
# ftp 192.168.0.78        // FTP server IP

-----------------------------------------------------------------------------------------

FTP -        Commands

A.) To Download a file

i.    get and mget command

# ftp 192.168.0.78            // FTP server IP
# get filename
# mget file1 file2 file3        // For Mutiple files

ii.    wget command

# wget ftp://192.168.0.78/pub/a        // FTP server IP ; a= filename

-----------------------------------------------------------------------------------------

B.) To upload a file

Server Side :

# yum install vsftpd -y
# service vsftpd restart
# chkconf vsftpd on
# cd /var/ftp/pub
# touch a b c d e
# vim /etc/vsftpd/vsftpd.conf
  anon_upload_enable=YES    // uncomment the line
  :wq
# service vsftpd restart
==========================================================================================

Client Side :

# ftp IPaddress
  name=anonymous
ftp> cd pub
ftp> put /root/Desktop/abc
===========================
Error recieved
227 : Enter Passive mode
553 : Could not create file
===========================

===================================================================================
NOte : Check the permission of PUB Folder, by default Write permission is not there
===================================================================================

# ls /var/ftp            // Donot have write permission
# chmod 777 /var/ftp/pub

===========================================================
Note : Change the group name of pub folder from Root to FTP
===========================================================

# chgrp ftp /var/ftp/pub

====================
Try again,Same Error
====================

==============================
Now, check for SE linux policy
==============================
# setenforce 0
# getsbool -a | grep ftp
# setsebool -P allow_ftp_anon_write on        // allow_ftp_anon_write = to allow annonymous user with write permission
# setenforce 1
# chcon -t public_content_rw-t pub/

==========
Try again,
==========

# ftp IPaddress
  name=anonymous
ftp> cd pub
ftp> put /root/Desktop/abc

-----------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------

No comments:

Post a Comment