Monday, December 16, 2013

RHCE Preparation/ How to configure FTP Server


  
  1.Install service

#yum install vsftpd
#chkconfig vsftpd on



    2.Set IPTABLES Rules



#iptables -I INPUT -p tcp --dport 21 -j ACCEPT
#service iptables save

   3.Set Selinux

#getsebool -a |grep ftp



[root@localhost Desktop]# getsebool -a |grep ftp
allow_ftpd_anon_write --> off
allow_ftpd_full_access --> off
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
ftp_home_dir --> off
ftpd_connect_db --> off
ftpd_use_passive_mode --> off
httpd_enable_ftp_server --> off
tftp_anon_write --> off

#setsebool -P ftp_home_dir on

    4.Anonymous download only

#vim /etc/vsftpd/vsftpd.conf

Comment local_enable=YES to allow local users to log in.; anonymous are enabled by default
# Uncomment this to allow local users to log in.
#local_enable=YES

# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=YES

    5.Load ip_conntrack_ftp Module

#vim /etc/sysconfig/iptables-config
IPTABLES_MODULES="ip_conntrack_ftp"

#service iptables restart 

#service vsftpd start

    6.Install FTP Client

#yum install ftp  (for the client)


  7. Download test file via ftp client

#ftp 192.244.12.33

Create file named test under /var/ftp/pub

#touch /var/ftp/pub/test

[root@localhost Desktop]# ftp 172.17.128.3
Connected to 172.17.128.3 (172.17.128.3).
220 (vsFTPd 2.2.2)
Name (172.17.128.3:root): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ^C
ftp> ls
227 Entering Passive Mode (172,17,128,3,249,247).
150 Here comes the directory listing.
drwxr-xr-x    2 0        0            4096 Dec 15 11:31 pub
226 Directory send OK.
ftp> cd pub
250 Directory successfully changed.
ftp> ls
227 Entering Passive Mode (172,17,128,3,76,79).
150 Here comes the directory listing.
-rw-r--r--    1 0        0               0 Dec 15 11:31 test
226 Directory send OK.
ftp> get test
local: test remote: test
227 Entering Passive Mode (172,17,128,3,146,62).
150 Opening BINARY mode data connection for test (0 bytes).
226 Transfer complete.
ftp>bye

No comments:

Post a Comment