Specific commands for FTP server configuration process (1)

Source: Internet
Author: User

This article mainly introduces the FTP server configuration process. In the previous article, we explained how to create an FTP server. We should also find some problems. From the previous article, we found that the FTP server user is also a system user. This is obviously a security risk because these users can not only access FTP, but also access other system resources. How can this problem be solved? The answer is to create an FTP server for a virtual user. A virtual user can only access the FTP service provided by the server, but cannot access other resources of the system. Therefore, if you want to grant the write permission to the FTP server station but do not allow access to other system resources, you can use virtual users to improve system security. In VSFTP, authentication for these virtual users uses a separate password library file pam_userdb), which is authenticated by the pluggable authentication module PAM. This method is safer and more flexible.

The following describes the FTP server configuration process.

FTP server configuration process 1. Generate a virtual user password library file. To create a password library file, you must first generate a text file. The file format is as follows: singular behavior username, even behavior password:

 
 
  1. #vi account.txt  
  2. ylg  
  3. 1234  
  4. zhanghong  
  5. 4321  
  6. gou  
  7. 5678  

FTP server configuration process 2. Generate a password library file and modify its permissions:

 
 
  1. #db_load -T -t hash -f ./account.txt /etc/vsftpd/account.db  
  2. #chmod 600 /etc/vsftpd/account.db  

FTP server configuration process 3. Create a virtual user's PAM file. Add the following two lines:

 
 
  1. #vi /etc/pam.d/vsftp.vu  
  2. auth required /lib/security/pam_userdb.so db=/etc/vsftpd/account  
  3. account required /lib/security/pam_userdb.so db=/etc/vsftpd/account  

FTP server configuration process 4. Create a virtual user, set the directory to be accessed by the user, and set the access permissions of the virtual user:

 
 
  1. #useradd -d /ftpsite virtual_user  
  2. #chmod 700 /ftpsite  

After this step,/ftpsite is the home directory of the virtual_user user, which is also the owner of the/ftpsite directory. Except the root user, only the user has the permission to read, write, and execute the directory.

FTP server configuration process 5. Generate a test file. First switch to the virtual_user user identity, and then create a file in the/ftpsite directory:

 
 
  1. #su -virtual_user  
  2. $vi /ftpsite/mytest  
  3. This is a test file.  
  4. $su - root  

FTP server configuration process 6. Edit the/etc/vsftpd. conf file so that the content of the entire file is as follows ):

 
 
  1. anonymous_enable=NO 
  2. local_enable=YES 
  3. local_umask=022 
  4. xferlog_enable=YES 
  5. connect_from_port_20=YES 
  6. xferlog_std_format=YES 
  7. listen=YES 
  8. write_enable=YES 
  9. anon_upload_enable=YES 
  10. anon_mkdir_write_enable=YES 
  11. anon_other_write_enable=YES 
  12. one_process_model=NO 
  13. chroot_local_user=YES 
  14. ftpd_banner=Welcom to my FTP server.  
  15. anon_world_readable_only=NO 
  16. guest_enable=YES 
  17. guest_username=virtual_user 
  18. pam_service_name=vsftp.vu  

In the code above, guest_enable = YES indicates that a virtual user is enabled; guest_username = virtual indicates that a virtual user is mapped to a local user, so that the virtual user can log on to the local user's virtual directory/ftpsite; pam_service_name = vsftp. the configuration file of PAM specified by vu is vsftp. vu.

FTP server configuration process 7. Restart VSFTP

 
 
  1. #service vsftpd restart  


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.