练习:完成vsftpd配置
(1) 禁锢系统用户于家目录
[root@node3 ~]# yum -y install vsftpd [root@node3 ~]# vim /etc/vsftpd/vsftpd.conf chroot_local_user=YES //大概在102行,启用此处的配置语句 [root@node2 ~]# ftp 10.1.43.103 Connected to 10.1.43.103 (10.1.43.103). 220 (vsFTPd 3.0.2) Name (10.1.43.103:root): gao 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> ls 227 Entering Passive Mode (10,1,43,103,28,138). 150 Here comes the directory listing. drwxr-xr-x 2 0 0 6 Oct 13 09:47 pub drwxrwxrwx 3 0 0 4096 Oct 15 12:50 upload 226 Directory send OK. ftp> pwd 257 "/" #禁锢成功
(2) 基于mysql进行用户认证
安装pam_mysql模块:
a:
[root@node3 ~]# yum -y install pam_mysql <CentOS 6上>b:
[root@node3 ~]# yum -y install mariadb-devel pam-devel [root@node3 ~]# wget 10.1.0.1:/pub/Sources/sources/pam/pam_mysql-0.7RC1.tar.gz [root@node3 ~]# tar -xf pam_mysql-0.7RC1.tar.gz [root@node3 ~]# cd pam_mysql-0.7RC1 [root@node3 pam_mysql-0.7RC1]# ./configure --with-pam=/usr --with-mysql=/usr --with-pam-mods-dir=/usr/lib64/security [root@node3 pam_mysql-0.7RC1]# make [root@node3 pam_mysql-0.7RC1]# make install修改vsftpd的配置文件:
[root@node3 ~]# vim /etc/vsftpd/vsftpd.conf guest_enable=YES //在末尾写上此3行,并把末尾向上5-6的位置中的 pam_service_name 这行注释掉 guest_username=vuser pam_service_name=vsftpd.mysql建立数据库:
[root@node3 ~]# mysql mysql> CREATE DATABASE vsftpd; mysql> CREATE TABLE vsftpd.users (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, name CHAR(30) NOT NULL UNIQUE KEY,password CHAR(48)); mysql> INSERT INTO vsftpd.users (name,password) VALUES ('tom',PASSWORD('mageedu')),('jerry',PASSWORD('mageedu')); mysql> GRANT ALL ON vsftpd.* TO 'vsftpd'@'localhost' IDENTIFIED BY 'mageedu'; mysql> GRANT ALL ON vsftpd.* TO 'vsftpd'@'127.0.0.1' IDENTIFIED BY 'mageedu'; mysql> FLUSH PRIVILEGES;vsftpd通过pam_mysql进行认证的配置文件:
[root@node3 ~]# vim /etc/pam.d/vsftpd.mysql auth required /usr/lib64/security/pam_mysql.so user=vsftpd passwd=mageedu host=127.0.0.1 db=vsftpd table=users usercolumn=name passwdcolumn=password crypt=2 account required /usr/lib64/security/pam_mysql.so user=vsftpd passwd=mageedu host=127.0.0.1 db=vsftpd table=users usercolumn=name passwdcolumn=password crypt=2准备匿名用户映射的系统用户账号:
[root@node3 ~]# mkdir /ftproot [root@node3 ~]# useradd -d /ftproot vuser [root@node3 ~]# mkdir /ftproot/{pub,upload} [root@node3 ~]# setfacl -m u:vuser:rwx /ftproot/upload登录用户:
[root@node2 ~]# ftp 10.1.43.103 Connected to 10.1.43.103 (10.1.43.103). 220 (vsFTPd 3.0.2) Name (10.1.43.103:root): tom 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> ls 227 Entering Passive Mode (10,1,43,103,215,37). 150 Here comes the directory listing. drwxr-xr-x 2 0 0 6 Oct 13 09:47 pub drwxrwxrwx 3 0 0 4096 Oct 15 12:50 upload 226 Directory send OK.
(3) 不同的虚拟用户拥有不同的权限设定
在配置(2)的基础上,配置每匿名用户有单独的权限设定
[root@node3 ~]# vim /etc/vsftpd/vsftpd.conf user_config_dir=/etc/vsftpd/vusers_conf #在末尾追加此语句创建目录:
[root@node3 ~]# mkdir /etc/vsftpd/vusers_conf为每用户提供配置文件:
[root@node3 ~]# /etc/vsftpd/vusers_conf/{tom,jerry}配置权限的指令:
[root@node3 ~]# vim /etc/vsftpd/vusers_conf/tom anon_upload_enable=YES|NO #注意不给指令:默认为NO anon_mkdir_write_enable=YES|NO anon_other_write_enable=YES|NO [root@node3 ~]# vim /etc/vsftpd/vusers_conf/jerry anon_upload_enable=YES|NO anon_mkdir_write_enable=YES|NO anon_other_write_enable=YES|NO
原创文章,作者:megedugao,如若转载,请注明出处:http://www.178linux.com/51930