{"id":6319,"date":"2016-10-11T16:22:28","date_gmt":"2016-10-11T08:22:28","guid":{"rendered":"http:\/\/rmohan.com\/?p=6319"},"modified":"2016-10-11T16:22:28","modified_gmt":"2016-10-11T08:22:28","slug":"centos-7-0-server-installation-configuration-vsftp","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=6319","title":{"rendered":"CentOS 7.0 server installation configuration vsftp"},"content":{"rendered":"<p>CentOS 7.0 server installation configuration vsftp<\/p>\n<p>First, configure the firewall to open the ports needed to FTP server<\/p>\n<p>CentOS 7.0 is the default firewall as a firewall, here to iptables firewall.<br \/>\n1, closed firewall:<\/p>\n<p>systemctl stop firewalld.service # Stop firewall<\/p>\n<p>systemctl disable firewalld.service # prohibit firewall boot<\/p>\n<p>2. Install iptables firewall<\/p>\n<p>yum install iptables-services # installation<\/p>\n<p>vi \/etc\/sysconfig\/iptables # edit the firewall configuration file<\/p>\n<p># Firewall configuration written by system-config-firewall<\/p>\n<p># Manual customization of this file is not recommended.<\/p>\n<p>*filter<\/p>\n<p>:INPUT ACCEPT [0:0]<\/p>\n<p>:FORWARD ACCEPT [0:0]<\/p>\n<p>:OUTPUT ACCEPT [0:0]<\/p>\n<p>-A INPUT -m state &#8211;state ESTABLISHED,RELATED -j ACCEPT<\/p>\n<p>-A INPUT -p icmp -j ACCEPT<\/p>\n<p>-A INPUT -i lo -j ACCEPT<\/p>\n<p>-A INPUT -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 22 -j ACCEPT<\/p>\n<p>-A INPUT -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 21 -j ACCEPT<\/p>\n<p>-A INPUT -m state &#8211;state NEW -m tcp -p tcp &#8211;dport 10060:10090 -j ACCEPT<\/p>\n<p>-A INPUT -j REJECT &#8211;reject-with icmp-host-prohibited<\/p>\n<p>-A FORWARD -j REJECT &#8211;reject-with icmp-host-prohibited<\/p>\n<p>COMMIT<\/p>\n<p>:wq! # Save and exit<\/p>\n<p>systemctl restart iptables.service # final restart firewall configuration to take effect<\/p>\n<p>systemctl enable iptables.service # firewall boot<\/p>\n<p>Description: 21 port is the ftp service port; 10060-10090 port Vsftpd passive mode is required, you can customize the period of greater than 1024 tcp port.<br \/>\nSELINUX<\/p>\n<p>vi \/etc\/selinux\/config<\/p>\n<p>#SELINUX=enforcing # # commented<\/p>\n<p>#SELINUXTYPE=targeted<\/p>\n<p>SELINUX=disabled<\/p>\n<p>:wq!<\/p>\n<p>setenforce 0<\/p>\n<p>Third, install vsftpd<\/p>\n<p>yum install -y vsftpd # install vsftpd<\/p>\n<p>yum install -y psmisc net-tools systemd-devel libdb-devel perl-DBI # installation vsftpd virtual user configuration dependencies<\/p>\n<p>systemctl start vsftpd.service # Start<\/p>\n<p>systemctl enable vsftpd.service # set vsftpd boot<\/p>\n<p>vsftp<\/p>\n<p>cp \/etc\/vsftpd\/vsftpd.conf \/etc\/vsftpd\/vsftpd.conf-bak back up the default profile<\/p>\n<p>Execute the following command set<\/p>\n<p>sed -i &#8220;s\/anonymous_enable=YES\/anonymous_enable=NO\/g&#8221; &#8216;\/etc\/vsftpd\/vsftpd.conf&#8217;<\/p>\n<p>sed -i &#8220;s\/#anon_upload_enable=YES\/anon_upload_enable=NO\/g&#8221; &#8216;\/etc\/vsftpd\/vsftpd.conf&#8217;<\/p>\n<p>sed -i &#8220;s\/#anon_mkdir_write_enable=YES\/anon_mkdir_write_enable=YES\/g&#8221; &#8216;\/etc\/vsftpd\/vsftpd.conf&#8217;<\/p>\n<p>sed -i &#8220;s\/#chown_uploads=YES\/chown_uploads=NO\/g&#8221; &#8216;\/etc\/vsftpd\/vsftpd.conf&#8217;<\/p>\n<p>sed -i &#8220;s\/#async_abor_enable=YES\/async_abor_enable=YES\/g&#8221; &#8216;\/etc\/vsftpd\/vsftpd.conf&#8217;<\/p>\n<p>sed -i &#8220;s\/#ascii_upload_enable=YES\/ascii_upload_enable=YES\/g&#8221; &#8216;\/etc\/vsftpd\/vsftpd.conf&#8217;<\/p>\n<p>sed -i &#8220;s\/#ascii_download_enable=YES\/ascii_download_enable=YES\/g&#8221; &#8216;\/etc\/vsftpd\/vsftpd.conf&#8217;<\/p>\n<p>sed -i &#8220;s\/#ftpd_banner=Welcome to blah FTP service.\/ftpd_banner=Welcome to FTP service.\/g&#8221; &#8216;\/etc\/vsftpd\/vsftpd.conf&#8217;<\/p>\n<p>echo -e &#8220;use_localtime=YES\\nlisten_port=21\\nchroot_local_user=YES\\nidle_session_timeout=300<\/p>\n<p>\\ndata_connection_timeout=1\\nguest_enable=YES\\nguest_username=vsftpd<\/p>\n<p>\\nuser_config_dir=\/etc\/vsftpd\/vconf\\nvirtual_use_local_privs=YES<\/p>\n<p>\\npasv_min_port=10060\\npasv_max_port=10090<\/p>\n<p>\\naccept_timeout=5\\nconnect_timeout=1&#8221; &gt;&gt; \/etc\/vsftpd\/vsftpd.conf<\/p>\n<p>Fifth, the establishment of virtual user list file<\/p>\n<p>touch \/etc\/vsftpd\/virtusers<\/p>\n<p>Edit the virtual user account list file \ud83d\ude41 first line, second line password, note: do not use the root user name, the system retained)<\/p>\n<p>vi \/etc\/vsftpd\/virtusers<\/p>\n<p>web1<br \/>\n123456<br \/>\nweb2<br \/>\n123456<br \/>\nweb3<br \/>\n123456<br \/>\n:wq!<\/p>\n<p>Sixth, to generate a virtual user data file<\/p>\n<p>db_load -T -t hash -f \/etc\/vsftpd\/virtusers \/etc\/vsftpd\/virtusers.db<\/p>\n<p>chmod 600 \/etc\/vsftpd\/virtusers.db # set the PAM authentication files and specify the virtual user database file for reading<\/p>\n<p>Seven, in \/etc\/pam.d\/vsftpd file header by adding the following information (later joined invalid)<\/p>\n<p>Before the amendment to the backup cp \/etc\/pam.d\/vsftpd \/etc\/pam.d\/vsftpdbak<br \/>\ncp \/etc\/pam.d\/vsftpd \/etc\/pam.d\/vsftpdbak<\/p>\n<p>vi \/etc\/pam.d\/vsftpd<\/p>\n<p>auth sufficient \/lib64\/security\/pam_userdb.so db=\/etc\/vsftpd\/virtusers<\/p>\n<p>account sufficient \/lib64\/security\/pam_userdb.so db=\/etc\/vsftpd\/virtusers<\/p>\n<p>Note: If your system is 32-bit, top to lib, otherwise, the configuration fails<\/p>\n<p>Eight, the new system user vsftpd, user directory is \/home\/wwwroot, user login terminal is set to \/bin\/false (even if they can not log into the system)<br \/>\nuseradd vsftpd -d \/home\/wwwroot -s \/bin\/false<\/p>\n<p>chown vsftpd:vsftpd \/home\/wwwroot -R<\/p>\n<p>chown www:www \/home\/wwwroot -R ## If the virtual host user user www, the need for such settings.<\/p>\n<p>Nine, to create a virtual user&#8217;s personal profile Vsftp<\/p>\n<p>mkdir \/etc\/vsftpd\/vconf<\/p>\n<p>cd \/etc\/vsftpd\/vconf<\/p>\n<p>touch web1 web2 web3 # to create three virtual user profile here<\/p>\n<p>mkdir -p \/home\/wwwroot\/web1\/http\/<\/p>\n<p>vi web1 # web1 edit user profiles, with other similar configuration file<\/p>\n<p>local_root=\/home\/wwwroot\/web1\/http\/<\/p>\n<p>write_enable=YES<\/p>\n<p>anon_world_readable_only=NO<\/p>\n<p>anon_upload_enable=YES<\/p>\n<p>anon_mkdir_write_enable=YES<\/p>\n<p>anon_other_write_enable=YES<\/p>\n<p>Ten, the final restart vsftpd server<\/p>\n<p>systemctl restart vsftpd.service<\/p>\n<p>???<\/p>\n<p>guest_username=vsftpd # user-specified virtual host user (new user is in front of us)<\/p>\n<p>guest_username=www # If the ftp directory is pointing to the root directory of the site for uploading Web site, you can specify the user&#8217;s virtual host user accounts to run nginx www, avoid many problems permission settings<\/p>\n<p>Sample doc is attached<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p><a href=\"http:\/\/rmohan.com\/wp-content\/uploads\/2016\/10\/doc1.txt\">doc1<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>CentOS 7.0 server installation configuration vsftp<\/p>\n<p>First, configure the firewall to open the ports needed to FTP server<\/p>\n<p>CentOS 7.0 is the default firewall as a firewall, here to iptables firewall. 1, closed firewall:<\/p>\n<p>systemctl stop firewalld.service # Stop firewall<\/p>\n<p>systemctl disable firewalld.service # prohibit firewall boot<\/p>\n<p>2. Install iptables firewall<\/p>\n<p>yum install iptables-services # [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[73],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6319"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=6319"}],"version-history":[{"count":1,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6319\/revisions"}],"predecessor-version":[{"id":6321,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/6319\/revisions\/6321"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=6319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=6319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=6319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}