In this post, I will guide to you how to install or create the ftp server in Linux operating system.
Generally FTP server is used to upload or download the files from server machine to client machine. FTP works on TCP 20/21 protocol, TCP port 20 is used for uploading and TCP 21 port is used for downloading purpose.
In this article, I will explain step by step method of ftp server creation and configuration.
Step by step method of FTP server installation and configuration:
1. In the initial step , we will install the all required rpm or packages on the Linux server using "YUM" utility.
#yum install vsftpd*
If you have source rpm packages then you can install it. In our case we will install the rpm with yum. Using above command all the ftp packages and their dependency are installed.
2. Once the required packages has been installed successfully on the Linux server, we will start the ftp services on the server.
#service vsftpd start
Once the service start successfully we will make permanent it so after reboot of server it would be enable always.
#chkconfig vsftpd on
Once the service start successfully we will make permanent it so after reboot of server it would be enable always.
#chkconfig vsftpd on
3. Now, to check the location of ftp server file which we upload or create after ftp server installation.
#cd /var/ftp/pub
#ls
And check the file which you have created after ftp server installation. If you find your created file here then you can ensure your ftp server has been installed successfully on Linux server.
4. Now for checking the ftp server using login in it.
4. Now for checking the ftp server using login in it.
# ftp Server IP address ( In my case server ip is 192.168.1.240)
Name(192.168.1.240:root):anonymous
Passwd (press enter) --- by defult anonymous password is blank
ftp> (It will show you have successfully enter in ftp server)
ftp> ls
pub ( will see this directory in ftp location)
ftp>cd pub
pub> mkdir vibhor
pub> permission denied (error getting)
5. To give the permission to make a directory in pub ,changes in this file
#vi /etc/vsftpd/vsftpd.conf
Uncomment all these below lines
anonymous_enable=yes
anon_upload_enable=yes
anon_mkdir_write_enable=yes
save the file
6. Now we will take a restart of the ftp services again. You can follow the step 2 to take a restart of ftp services.
7. In this step we will provide the permission to pub folder so that client user can read/write the file and folder in the default direcoty.
#chmod 777 /var/ftp/pub
In my case I will give the full permission to pub folder. You can set the permission according to your project requirement.
8. If you want to ensure that you are able to created and access the folder or not on ftp server then in this case you need to login again in ftp server.
#ftp 192.168.1.240
Name: anonymous
Passwd (enter)
ftp> Cd pub
pub>mkdir vibhor
vibhor (directory created)
pub>ls
vibhor
If you want to check the directory which we created in above text please go to the below location and find it
#cd /var/ftp/pub
Pub]#ls
Vibhor
So now you will get the file on the ftp pub folder which you created that means the permission which you provide to the user are working properly.
9. You want only one user is able to login by ftp server and access only one particular folder, also not able to delete the file and folder on ftp server, having a ability of uploading and downloading through ftp server. For this thing we have to change in configuration file and chroot_list, ftpuser file.
First create a user which you want to access for ftp user
So now you will get the file on the ftp pub folder which you created that means the permission which you provide to the user are working properly.
9. You want only one user is able to login by ftp server and access only one particular folder, also not able to delete the file and folder on ftp server, having a ability of uploading and downloading through ftp server. For this thing we have to change in configuration file and chroot_list, ftpuser file.
First create a user which you want to access for ftp user
# useradd -s /sbin/nologin ttftpuser (His shell is nologin so other user not login)
#passwd ttftpuser
Now create a folder in ttftpuser which you want to give access
#cd /home/ttftpuser
ttftpuser~]#mkdir noidaftp
ttftpuser~]#chmod 777 noidaftp
Now go to the file chroot_list, add the user only which you want to give access.
#vi /etc/vsftpd/chroot_list
ttftpuser (make a entry of user which you want to give access)
Now if you want no other user login in ftp server then entry all those user except chroot_list user in ftpuser file.
#vi /etc/vsftpd/ftpuser
Promartuser (these are users on which ftp server is make )
Vibhor
Now go to configuration file and make changes in file and change all the parameter which is required on the configuration files.
#vi /etc/vsftpd/vsftpd.conf
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
syslog_enable=NO
dual_log_enable=YES
vsftpd_log_file=/var/log/vsftpd.log
xferlog_file=/var/log/xferlog
xferlog_std_format=YES
ftpd_banner=*************************Welcome to blah FTP service******************
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
listen=YES
pam_service_name=vsftpd
userlist_enable=YES
tcp_wrappers=YES
listen_port=54321
cmds_allowed=ABOR,ACCT,ALLO,APPE,CDUP,CWD,EPRT,EPSV,FEAT,HELP,LIST,MDTM,MKD,MODE,NLST,NOOP,OPTS,PASS,PASV,PORT,PWD,QUIT,REIN,REST,RETR,RMD,RNFR,RNTO,SITE,SIZE,SMNT,STAT,STOR,STOU,STRU,SYST,TYPE,USER,XCUP,XCWD,XMKD
Save the file for above changes which is in bold text in file and restart the ftp services which is describe in step 2.
Save the file for above changes which is in bold text in file and restart the ftp services which is describe in step 2.
#service vsftpd restart
Now check login on console mode
#ftp 192.168.1.243 54321
Enter username:ttftpuser
Passwd..enter the passwd
ftp> you have successfully enter
ftp>ls
noidaftp (folder you have seen)
ftp>put vsftpd.conf (it will upload file )
ftp>get vsftpd.org (it will download file)
If you want to change the user shell please run the below command method as describe below.
#usermod -s /sbin/nologin username
#usermod -s /bin/bash username
So using above method we can easily installed and configured the ftp server on Linux operating system.