Install the FTP server on CentOS7

Source: Internet
Author: User

Install the FTP server on CentOS7

Suppose we have the following requirements:

Path permission remarks/ftp/open Company all personnel including guests can access read-only/ftp/private only allow access by Alice, Jack, and Tom

Alice and Jack can only be downloaded,

Tom can upload all files using a virtual account

Install FTP// Use yum to install # yum-yinstallftpvsftpd // or use rpm to install the following two packages of ftp-0.17-66.el7.x86_64vsftpd-3.0.2-9.el7.x86_64 // you also need to install the db package, used to encrypt the account information of the virtual user // This package has been installed by default in centos7 # rpm-qf/usr/bin/db_loadlibdb-utils-5.3.21-17.el7_0.1.x86_64Configuration# Mkdir/ftp/open test files # echoopentest>/ftp/open/open.txt # echofiletest>/tmp/filetest1.txt # touch/ftp/open/anontest.txt // view the configuration file path # rpm-qcvsftpd/etc/logrotate. d/vsftpd/etc/pam. d/vsftpd/etc/vsftpd/ftpusers/etc/vsftpd/user_list/etc/vsftpd. conf # cd/etc/vsftpd // back up the original configuration file # cpvsftpd. confvsftpd. conf. origin // create password plaintext file # vi/etc/vsftpd/vftpuser.txt aliceP @ ssw0rdjackP @ ssw0rdtomP @ ssw0rd // create password DB File Based on plaintext # db_load-T-thash-f/etc/vsftpd/vftpuser.txt \/ etc/vsftpd/vftpuser. db // view the password data file # file/etc/vsftpd/vftpuser. db/etc/vsftpd/vftpuser. db: BerkeleyDB (Hash, version9, nativebyte-order) // create a vftpd guest Account # useradd-d/ftp/private-s/sbin/nologinvftpuser # vi/etc/pam. d/vsftpd comment out all the configuration line lines of auth and account and add the following content: authrequiredpam_userdb.sodb =/etc/vsftpd/vftpuseraccountrequiredpam_userdb.sodb =/etc/vsftpd/vftpuser // open the configuration file # vi/etc/vsftpd. conf // Add anon_root =/ftp/openvirtual_use_local_privs = YESguest_enable = YESguest_username = Enabled = YES // set automatic start # restart-s '/usr/lib/systemd/system /vsftpd. service ''/etc/systemd/system/multi-user.target.wants/vsftpd. service '# systemctlstartvsftpd // view the current status # systemctlstatusvsftpdvsftpd. service-VsftpdftpdaemonLoaded: loaded (/usr/lib/systemd/system/vsftpd. service; enabled) Active: active (running) sinceMon2014-08-1119: 57: 12CST; 22 hagoMainPID: 12733 (vsftpd) CGroup:/system. slice/vsftpd. servicea "a" 12733/usr/sbin/vsftpd/etc/vsftpd. conf1_emd [1]: StartingVsftpdftpdaemon... systemd [1]: StartedVsftpdftpdaemon. vsftpd [12738]: pam_userdb (vsftpd: auth): user 'Alice 'grantedaccessvsftpd [12753]: pam_userdb (vsftpd: auth): user 'jack' grantedaccesssystemd [1]: Example.

Test

// Test the anonymous account # ftplocalhostTrying: 1... connectedtolocalhost (: 1 ). 220 (vsFTPd3.0.2) Name (localhost: root): anonymous331Pleasespecifythepassword. password: 230Loginsuccessful. remotesystemtypeisUNIX. usingbinarymodetotransferfiles. ftp> ls229EnteringExtendedPassiveMode (||| 61057 | ). 150Herecomesthedirectorylisting. -rw-r -- 1009Aug1111: 45open.txt 226DirectorysendOK. ftp> LCD/tmpLocaldirectorynow/tmpftp> getopen.txt local: op En.txt remote: open.txt 229 EnteringExtendedPassiveMode (| 64276 | 2.16.150openingbinarymodedataconnectionforopen.txt (9 bytes ). 226Transfercomplete. 9bytesreceivedin0. 000895 secs (10.06 Kbytes/sec) ftp> bye221Goodbye. // test the Local Account # ftplocalhostTrying: 1... connectedtolocalhost (: 1 ). 220 (vsFTPd3.0.2) Name (localhost: root): alice331Pleasespecifythepassword. password: 230Loginsuccessful. remotesystemtypeisUNIX. usingbinarymodetotra Nsferfiles. ftp> ls229EnteringExtendedPassiveMode (||| 21750 |). 150Herecomesthedirectorylisting. 226DirectorysendOK. ftp>! Ls/tmpfiletest1.txtopen.txtsystemd-private-9xPN7yvmware-fonts0vmware-installer1vmware-rootvmware-tools-distribks-script-_Yi85RSAMBA.docx vmware-config0vmware-installer0vmware-installer2vmware-root-2117481760yum.logftp> LCD/tmpLocaldirectorynow/tmpftp> putfiletest1.txtlocal: filetest1.txtremote: filetest1.txt229EnteringExtendedPassiveMode (| 65399 | ). 150Oktosenddata. 226Transfercomplete. 9bytessentin5. 9e-05secs (152.54 Kbytes/sec) ftp> bye221Goodbye.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.