August 7, 2014

RHEL 6 FTP Configure Anonymous-Only Download.

Installation

yum install vsftpd -y

Configuration

$ vi /etc/vsftpd/vsftpd.conf
...
# Allow anonymous FTP?
anonymous_enable=YES
..
# Uncomment this to allow local users to log in.
local_enable=NO
...
# Uncomment this to enable any form of FTP write command.
write_enable=NO
...

Start

service vsftpd restart; chkconfig vsftpd on

Firewall

$ vi /etc/sysconfig/iptables
...
-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT 
...
$ vi /etc/sysconfig/iptables-config
...
IPTABLES_MODULES="nf_nat_ftp nf_nat_tftp"
...
$ service iptables restart
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]
iptables: Loading additional modules: nf_nat_ftp nf_nat_tft[  OK  ]

Test

Create test data.

$ echo "Hello" >> /var/ftp/pub/hello.txt

$ restorecon -RFv /var/ftp/pub/hello.txt 
restorecon reset /var/ftp/pub/hello.txt context unconfined_u:object_r:public_content_t:s0->system_u:object_r:public_content_t:s0

And download it from remote host.

$ lftp 192.168.1.11
lftp 192.168.1.11:~> ls
drwxr-xr-x    2 0        0            4096 Aug 07 19:22 pub
lftp 192.168.1.11:/> cd pub/
lftp 192.168.1.11:/pub> ls
-rw-r--r--    1 0        0               6 Aug 07 19:22 hello.txt
lftp 192.168.1.11:/pub> get hello.txt 
6 bytes transferred
lftp 192.168.1.11:/pub> exit

# cat hello.txt 
Hello

No comments: