Vsftpd+pam_mysql Virtual User Configuration

Source: Internet
Author: User

Company Project Requirements:

Our company is Cosmetics e-commerce company

1. Set up an FTP server to upload parcel express face picture, to achieve basic upload and download function

2.VSFTPD login via virtual user, can be accessed outside the network

3. Restrict Virtual User Login IP

4. Virtual user-related profiles can be added to the interface, modify, etc., and to update in a timely manner


The following are mainly 1, 22 steps to implement the procedures and precautions

3, 42 step in another blog with detailed instructions and code (Vsftpd+pam_mysql+shell)


Install Pam_mysql (please be sure to install, the following installation VSFTPD Error 3 is explained) No MySQL installation is given here

CD PAM_MYSQL-0.7RC1

./configure--with-mysql=/home/mysql/app/mysql5/

Make && make install

Installation Error:

1. PAM Unable to Dlopen (/lib/security/pam_mysql.so): Libmysqlclient.so.18:cannot Open Shared object file:permission denied

CP mysql_dir/lib/libmysqlclient.so.18/usr/lib64/It is important to note that creating a soft connection does not have to be replicated, and that the file permissions must be user rights for MySQL. Otherwise you won't be able to log in, and will not report anything wrong


Installing VSFTPD

Note:

CentOS 32-bit direct Yum installation

Centos64 bit requires compile and install, if Yum installation error:Libgcc_s.so.1 must be installed for Pthread_cancel


Tar zxvf vsftpd.3-2

Vim Defs.h

Modify the following line to resolve the above problem (libgcc_s.so)

#define VSFTP_AS_LIMIT 100UL * 1024 * 1024

#define VSFTP_AS_LIMIT 400UL * 1024 * 1024


Vim Builddefs.h

Modify the following line, the mode tcpwrappers to be used when configuring VSFTPD, if not configured, will error:

Oops:tcp_wrappers is set to YES and no TCP wrapper support compiled in

#Unfin vsf_build_tcpwrappers

#Define vsf_build_tcpwrappers


More install view installation items, these are generally good, here is just a mention of

Make && make install


Some errors occurred during the installation process:

1.tcpwrap.c:16:20: Error: tcpd.h: No file or directory

Yum install-y tcp_wrappers Tcp_wrappers-devel

2./usr/bin/ld:cannot find-lcap

Yum-y Install Libcap libcap-devel (LCAP is a protocol active mode, passive mode to realize link dynamic aggregation )

3.530 Login Incorrect vsftpd+pam_mysql configuration everything is ok but just can't log in, began to never know

Where there is a problem, and then carefully check the vsftpd dependencies, just know pam_mysql dependency relationship did not (ldd/usr/local/sbin/vsftpd)

Before installing VSFTPD, install Pam_mysql


Configure VSFTPD

CP vsftpd.conf/etc/ configuration file must be placed in/etc

CP REDHAT/VSFTPD.PAM/ETC/PAM.D/VSFTPD


The following is the online FTP service configuration template that is being used (parameters are not listed)

Vim vsftpd.conf

Anonymous_enable=yesno_anon_password=yesftp_username=ftpanon_root=/var/ftpanon_upload_enable=noanon_world_ readable_only=yesanon_mkdir_write_enable=noanon_other_write_enable=noanon_max_rate=0#chown_uploads=yes/no# chown_username=username#anon_umask=077#deny_email_enable=yes/no#banned_email_file=/etc/vsftpd/banner_emails#[ Local] #login  name:local user, login passwd:local passwd, ftp dir:local  path, exclude user in:/etc/vsftpd.ftpusersisolate_network=nolocal_enable=yeslocal_root=/ Home/virtuallocal_umask=077file_open_mode=0755local_max_rate=0#chroot_list_enable=yes,chroot_local_user=yes: Vsftpd.chroot_list is allow#chroot_list_enable=yes,chroot_local_user=no:vsftpd.chroot_list is  deny#chroot_list_enable=no,chroot_local_user=yes:all deny#chroot_list_enable=no,chroot_local_user= No:all allowchroot_list_enable=no#chroot_list_file=/etc/vsftpd/chroot_listchroot_local_user=noallow_ writeable_chroot=yes#[welcome Message] #message  type:file or string#dirmessage_enable=yes#message_file=.message#banner_file=/ Etc/vsftpd/bannerftpd_banner=welcome to test ' S ftp server#[other]text_userdb_names=nols_ Recurse_enable=nohide_ids=nodownload_enable=yes#[globle] #all  config is about this  Globle configwrite_enable=no#[transfer mode] #image  or exec file:binary,cgi file  or html file:ascii#ascii_upload_enable=no#ascii_download_enable=no#[access control] #type: Host control (Hosts.allow)  ,user control  ftpusers level is gt  vsftpd.user_listtcp_wrappers=yesuserlist_enable=yesuserlist_file=/etc/vsftpd/user_listuserlist_deny=yes#[ Timeout]accept_timeout=60connect_timeout=60data_connection_timeout=120idle_session_timeout=300#[logfile] Xferlog_enable=yesxferlog_file=/var/log/vsftpd.logxferlog_std_format=nolog_ftp_protocol=yes#[ftp work  type and work Port] #work  type:port ftp and pasv ftplisten_port=22#connect_from_port_20=yes#ftp_data _port=20#pasv_addr_resolve= #pasv_address = #pasv_promiscuous =pasv_enable=yespasv_max_port=53001pasv_min_port= 52999#[connect]listen=yesmax_clients=100max_per_ip=10use_localtime=yes#listen_address=ip#setproctitle_enable= No#[pam user]       guest_enable=yespam_service_name=vsftpdguest_ Username=virtualvirtual_use_local_privs=nouser_config_dir=/etc/vsftpd/userconf

Note:

1.refusing to run with writable root inside Chroot ()

Allow_writeable_chroot=yes Add this sentence


Create Virtual Hosting User: Vsan dir:/home/virtual/

Create a virtual user test

User profiles:/etc/vsftpd/vuser_conf/test

With regard to user profiles, there are a number of parameters that can be set, which can be enhanced

Local_root=/home/virtual/test
Write_enable=yes
Anon_upload_enable=yes
Anon_world_readable_only=no
Anon_mkdir_write_enable=yes
Anon_other_write_enable=yes
CMDS_ALLOWED=PASV,TYPE,LIST,CWD,PWD,SIZE,CDUP,TYPE,MKD,MDTM,NLST,PASS,QUIT,USER,REIN,RETR,STOR,RNTO,APPE,RNFR, Dele,rmd

Note:

1.226 Transfer Done (but failed to open directory)

Test User directory permission must be set to 7XX the first must be 7 (all permissions) chmod


Configure Pam_mysql

Vim/etc/pam.d/vsftpd

The relevant parameters can be filled, PAM_MSYQL installation package also has relevant documentation

Auth required/lib/security/pam_mysql.so user= passwd= host= db= table= usercolumn= passwdcolumn= crypt=0
Account required/lib/security/pam_mysql.so user= passwd= host= db= table= usercolumn= passwdcolumn= crypt=0


About External network access:

When an extranet accesses FTP, it is important to note that, through passive mode access, the data port of the extranet map must be contiguous, otherwise the client cannot establish the link, and I encounter the following error in the link:

Using host address instead of the one suggested by the server:


VSFTPD +SSL Encrypted transmission

Not configured at the moment because it felt like a special trouble applying for a certificate

This article is from the "Small white" blog, please be sure to keep this source http://wjp13671142513.blog.51cto.com/9141365/1536673

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.