The Ultimate Guide to Setting Up FTP Server on Linux

ARN Tech Trainings
ARN Tech Trainings
428 بار بازدید - 11 ماه پیش - FTP (File Transfer Protocol) SERVER:
FTP (File Transfer Protocol) SERVER: Step1: Install the package: • Install the package using yum or rpm command. #yum install vsftpd* -y Okay now we are done with the installation. Check it with #rpm –q vsftpd command If you don’t have yum repository created, then installed it using rpm from RHEL DVD Step2: Copy or create some files in “/var/ftp/pub” directory • Navigate to /var/ftp/pub directory and create some files in it #cd /var/ftp/pub #touch file{1..5} Step3: Restart the ftp service #service vsftpd restart Step4:- Make the service enable even after reboot of the system • To make a service enable use the following command #chkconfig vsftpd on Step5:- Connect from client and access the files and download it • To access the ftp server the client should have “ftp” package installed. If not installed, install it using rpm, because yum will not work if ftp package is not installed. • Check whether ftp package is installed or not in client machine #rpm –q ftp • To install ftp package either download it from redhat website or install it from RHEL DVD • Move to the package folder and installed it. #rpm –ivh package name • Check it by using rpm –q command #rpm -a ftp • Now connect to ftp server using its IP • To connect to ftp server use the following command #ftp ftp server’s IP #ftp 192.168.10.93 • Use “ftp or anonymous” as login name Press enter without giving any password • Navigate to pub directory and check the files available #cd pub Note:- when you run ls command you can see that it showing that we are using Passive mode. • Download some files using get or mget command • To download files use the following command #get file name for single file #mget file names for multiple files Before going for mget turn off the interactive mode, otherwise it will ask permission for every file you are downloading. Use #prompt command to turn off interactive mode. • Exit the ftp server and check whether the files are there or not • To exit the ftp server either use #bye or #quit Step6: Need to add port numbers 21/20 in firewalld. sudo iptables -I INPUT -p tcp -m tcp --dport 21 -j ACCEPT sudo iptables -I INPUT -p tcp -m tcp --dport 20 -j ACCEPT • To connect to the ftp server graphically open web browser like firefox type the ftp server’s ip address as following • ftp://192.168.223.128 Configuring the ftp server for uploading a file: To upload the files in the ftp server the steps are: Step1:- Create an upload dir in the document root of ftp server i.e., /var/ftp #mkdir upload #cd /var/ftp #ls #mkdir upload #ls Step2:- Change the group to “ftp” and write permission to the “upload” directory • Changing the group of upload to ftp #chgrp group name directory name #chgrp ftp upload #ls -ld upload #chgrp ftp upload ls -ld upload Adding the write permission to upload directory #chmod g+w upload #ls -ld upload #chmod g+w upload #ls -ld upload Step3:- Log into client machine, access ftp server and try to upload some files • Log into client machine and access the ftp server from the directory in which the files to be uploaded are there. #cd sample #ls • Navigate to upload directory and try to upload some files Once you logged into ftp and if you are not sure what is names of the files you want to upload then use “#!ls” command to see the content of the directory from which you have logged into ftp server. #ftp cd upload #ftp!ls #prompt #mput ktfil1 ktfile2 ktfile3 #vim /etc/vsftpd/vsftpd.conf Uncomment (remove the #) the following line • Restart the ftp service #service vsftpd restart Step4:- Again login to client system and try again to upload the files into ftp server • Check the Booleans for ftp using following command #getsebool –a |grep ftp • Make the above Boolean value as “on” • To make it on use the following command #setsebool –P allow_ftpd_anon_write on Add read write permission in context of upload directory using following command #chcon –t public_content_rw_t • Finally login into client machine, access the ftp server and try uploading the files in it. #ftp 192.168.223.128 • Allowing root access to the ftp server • By default root user is blocked to be used in ftp user, try logging with root in ftp server #ftp 192.168.223.128 • To Allow the root access to ftp server edit the “/etc/vsftpd/user_list” and “/etc/vsftpd/ftpuser” and just add the comment (#mark) before “root” #vim /etc/vsftpd/user_list #vim /etc/vsftpd/ftpuser Note:- restart the service #service ftp restart (or) #systemctl restart vsftpd • Now try login from client into ftp server as root #ftp 192.168.223.128 #getsebool -a | grep ftp Change the Boolean value to on for ftp_home_dir by following command #setsebool –P ftp_home_dir on Try logging again as root in ftp server #ftp 192.168.223.128 #FileTransfer #ActiveFTP #PassiveFTP #FTPConnection #UploadFiles #arn #arntech #arntraining #arntrainings #arntechtrainings ARNTech,vsftpd,ftps,mget,mput,The Ultimate Guide to Setting Up FTP Server on Linux
11 ماه پیش در تاریخ 1402/09/03 منتشر شده است.
428 بـار بازدید شده
... بیشتر