使用mysql驗證配置ftp伺服器

來源:互聯網
上載者:User

標籤:linux   mysql   ftp   

配置說明:

1、mysql伺服器:CentOS6.6    192.168.1.62

2、vsftpd伺服器:CentOS6.6    192.168.1.61


一、配置mysql伺服器

1、安裝mysql

[[email protected] ~]# yum -y install mysql-server[[email protected] ~]# service mysqld start[[email protected] ~]# mysql

2、準備資料庫及相關表

mysql> create database vsftpd;Query OK, 1 row affected (0.00 sec)mysql> grant select on vsftpd.* to [email protected] identified by ‘123456‘;Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;mysql> create table users ( id int auto_increment not null, name char(20) binary not null, password char(48) binary not null, primary key (id) );Query OK, 0 rows affected (0.08 sec)

2、添加測試使用者

mysql> insert into users (name,password) values (‘zhangsan‘,password(‘123456‘));Query OK, 1 row affected (0.00 sec)mysql> insert into users (name,password) values (‘lisi‘,password(‘123456‘));    Query OK, 1 row affected (0.00 sec)

二、配置vsftpd

1、安裝epel源

[[email protected] ~]# rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-6.noarch.rpm

2、安裝vsftpd服務及pam_mysql認證

[[email protected] ~]# yum -y install vsftpd pam_mysql

3、建立pam認證所需要的檔案

# vim /etc/pam.d/vsftpd.mysqlauth required pam_mysql.so user=vsftpd passwd=123456 host=192.168.1.62 db=vsftpd table=users usercolumn=name passwdcolumn=password crypt=2account required pam_mysql.so user=vsftpd passwd=123456 host=192.168.1.62 db=vsftpd table=users usercolumn=name passwdcolumn=password crypt=2

4、添加虛擬使用者對應的系統使用者,使其適用mysql認證

[[email protected] ~]# useradd -s /sbin/nologin -d /var/ftproot vuser[[email protected] ~]# chmod +rx /var/ftproot/

5、修改vsftpd的設定檔

請確保/etc/vsftpd.conf中已經啟用了以下選項anonymous_enable=NOlocal_enable=YESwrite_enable=YESanon_upload_enable=NOanon_mkdir_write_enable=NOchroot_local_user=YES而後添加以下選項guest_enable=YESguest_username=vuser並確保pam_service_name選項的值如下所示pam_service_name=vsftpd.mysql

6、重啟服務並進行驗證

[[email protected] vsftpd]# service vsftpd restart

三、配置虛擬使用者具有不同的存取權限

vsftpd可以在設定檔目錄中為每個使用者提供單獨的設定檔以定義其ftp服務存取權限,每個虛擬使用者的設定檔名同虛擬使用者的使用者名稱。設定檔目錄可以是任意未使用目錄,只需要在vsftpd.conf指定其路徑及名稱即可。

1、配置vsftpd為虛擬使用者使用設定檔目錄


# vim vsftpd.conf

添加如下選項

user_config_dir=/etc/vsftpd/vusers_config 


2、建立所需要目錄,並為虛擬使用者提供設定檔


# mkdir /etc/vsftpd/vusers_config/

# cd /etc/vsftpd/vusers_config/

# touch zhangsan lisi


3、配置虛擬使用者的存取權限


虛擬使用者對vsftpd服務的存取權限是通過匿名使用者的相關指令進行的。比如,如果需要讓tom使用者具有上傳檔案的許可權,可以修改/etc/vsftpd/vusers_config/tom檔案,在裡面添加如下選項即可。

anon_upload_enable={YES|NO}

anon_mkdir_write_enable={YES|NO}

anon_other_write_enable={YES|NO}



本文出自 “追夢” 部落格,請務必保留此出處http://387227.blog.51cto.com/377227/1831845

使用mysql驗證配置ftp伺服器

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.