Wednesday, 12 February 2014

Create an FTP Server With VSFTPD Centos 6.4

                                             

What is FTP ?
FTP stands for File Transfer Protocol. An FTP server allows clients to connect to it either
anonymously or with a username and password combination.


which port VSFTP server works ?
FTP uses two ports, 20 and 21. By default, the FTP server listens for requests on port 21.After a connection is established, the client sends commands to the server on port 21. However, port 20 is used when the server sends data back to the client.

Install the Vsftpd service.

#yum install vsftpd
Default ftp port : 21
Default configuration file : /etc/vsftpd.conf

Edit the Configuration file and UN-comment it .
#vim /etc/vsftpd/vsftpd.conf
anon_upload_enable=NO --> anonymous disable
xferlog_enable=YES -->create logrotate log file
xferlog_file=/var/log/xferlog -->file contains logging information from the FTP server

Note :- User restricted to access other directory apart from user ftp directory.
chroot_local_user=NO
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
Note :- Save and exit from the file

create file under /etc/vsftpd directory
#touch /etc/vsftpd/chroot_list

Start Vsftpd Service :
# service vsftpd start

Make Vsftpd Service auto start on boot up :
# chkconfig vsftpd on

Port listen command :
#netstat -tulpn | grep vsftpd ---> port listen or not

Configure Selinux :
# 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_disable_trans --> off
ftpd_is_daemon --> on
httpd_enable_ftp_server --> off
tftpd_disable_trans --> off

Selinux status : 
# getenforce
Enforcing

For normal users set Boolean
# setsebool -P ftp_home_dir on

Add these rules to your iptables configuration:
#iptables -A INPUT -p tcp --dport 21 -j ACCEPT
#iptables -A OUTPUT -p tcp --sport 20 -j ACCEPT

Ensure that the space-separated list of modules contains the FTP connection-tracking module
# vim /etc/sysconfig/iptables-config
IPTABLES_MODULES="ip_conntrack_ftp"
Note : Save and close the file 

Save iptables services :
# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:    [  OK  ]

Restart iptables services :
# service iptables restart

Restart vsftpd services and Testing it :
# service vsftpd restart
Shutting down vsftpd:                                          [  OK  ]
Starting vsftpd for vsftpd:                                    [  OK  ]

vsftpd status 
# service vsftpd status
vsftpd (pid 5531) is running...

create users for ftp access (eg: vino)
Note :- use the below command to create the user in nologin shell(recommended)
#mkdir /var/ftp_package
#useradd -s /sbin/nologin -d /var/ftp_package vino
#passwd vino
Note :- In order to enable the ftpuser read and write the data in your home dir, change the permission and take ownership:
#chown -R vino:vino /var/ftp_package
#chmod 775 /var/ftp_package

Add user vino to file to allow ftp access
#vim /etc/vsftpd/chroot_list
#add the user ‘vino’ to the file
vino
Note :- Save and exit from the file

connect to VSFTPD  Server using command line.
1.Type ftp and enter to continue.
2.Type open and enter to continue.
3.Type ftp server ip address and enter to connect to ftp server.
4.If connected, type login name and enter.
5.Type user password and enter. If the username and password are valid, then you'll be in.

#ftp
ftp> open
(to) 192.168.4.25
Connected to 192.168.4.25
---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 10:42.
Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name : vino
Password required
Password: enter password of vino

list a directory content in ftp server:
ftp> ls
200 PORT command successful
150 Connecting to port 39545
-rwxrwxrwx 1 vino vino 16 Nov 4 06:36 File.txt

FTP command :-
The ftp command used to download a single file from a server is get.
The ftp command used to download a multiple files from a server is mget.
The ftp command used to upload a single file to a server is put.
The ftp command used to upload a multiple files to a server is mput.
If you want to exit frm ftp, use ftp 
#bye 


Monitor clients connected to vsftpd :-
Add the configure file vim /etc/vsftpd/vsftpd.conf
Make sure you have enabled the config option, "setproctitle_enable=YES" and restart your vsftpd server
#ps -Cvsftpd -o user, pid, stime, cmd


For Windows 7 :-
Use FileZilla - An FTP Client to Upload, Download and Manage files
Download URL :-








No comments:

Post a Comment

Configure EKS Persistent Static Storage With Elastic File System Using Terraform

  checkout :https://youtu.be/QuUIgQWBBZM