Linux system to learn eighteen, VSFTP service - Virtual User Access - Configure Virtual User Access

Configuring Virtual User Access

To close the first of at least userlist

 

 

 

End change the configuration file to restart the service to make it take effect

In fact, in the case when the profile of the newly installed vsftp without modifying the configuration of the virtual user access control is the best

local_root option does not affect

Directory and virtual users log on locally logged on user does not have an impact

In order to prevent an impact, but also annotated the chroot

 

 

User login virtual configuration steps:

1, add the virtual user password file

2, generates virtual user password authentication file

3, edit the PAM authentication file vsftp

4, set up a local map and user home directory permissions

5, modify the configuration file

6, vsftp restart the service, and tested

7, adjust the virtual user rights

 

The first step: add the virtual user password file (the file can be called any name can be placed in any position)

vi /etc/vsftpd/vuser.txt # follows

  cangls # Username

  123 # Password

  bols # Username

  123 # Password

More than one user name and password and can not log in directly to the system, so afraid of interception

 

 

 

 

Step Two: Generate a virtual user password authentication file

yum -y install db4-utils # If password authentication command is not installed, you need to install

db_load -T -t hash -f /etc/vsftpd/vuser.txt /etc/vsftpd/vuser.db # text documents into the database authentication

-T: Transformation

-t: Specifies the conversion function

-f: Specifies the file

 

 

 

 

Step Three: Edit the PAM authentication file vsftp

we /etc/pam.d/vsftpd

auth required /lib/security/pam_userdb.so db=/etc/vsftpd/vuser

account required /lib/security/pam_userdb.so db=/etc/vsftpd/vuser

# Comment out other lines, two lines can be added

# Comment other line, you can disable local user logs in, because of the local user login authentication is still rely on this document

The file itself has a number of rules that define a local user validation rules

 

 

 

Vsftp profile of the bottom there is a line set, the file is pam

 

 

 

vi中将2~8行添加#号

 

 

 

 

添加修改完成后,重启服务

 

 

 

此时本地用户就不能登录了

 

第四步:建立本地映射用户并设置宿主目录权限

useradd –d /home/vftproot –s /sbin/nologin vuser   #此用户不需要登录,只是映射用户

#用户名必须和下一步配置文件中一致

chmod 775 /home/vftproot

 

 

 

创建完成后的vftproot的权限是700,这种权限下是不允许用户上传的,需要改权限为755

 

第五步:修改配置文件

vi /etc/vsftpd/vsftpd.conf

  guest_enable=YES      #开启虚拟用户

  guest_username=vuser     #FTP虚拟用户对应的系统用户(用户名要和前面的名字一样)

  pam_service_name=vsftpd        #PAM认证文件(默认存在)

 

 

 

 

第六步:重启vsftpd服务并测试

service vsftpd restart

此时虚拟用户可以登录,查看、下载,不能上传

默认上传文件的位置是宿主用户的家目录

权限使用的是匿名用户权限进行管理

 

注:正常情况下,此时就可以用前面设置的两个虚拟用户登录ftp了,但是我这里是登陆失败,还没找的是哪里出错了,下面我重新恢复虚拟机,重头再来。

 

第七步:调整虚拟用户权限(不能上传的问题)

vi /etc/vsftpd/vsftpod.conf

  anonymous_enable=NO     #关闭匿名用户登录,更加安全(不影响虚拟用户登录)

  anon_upload_enable=YES

  anon_mkdir_write_enable=YES

  anon_other_write_enable=YES

#给虚拟用户设置权限,允许所有虚拟用户上传

对于虚拟用户的文件目录中上传的权限,除了ftp的权限以外还需要系统对文件的权限设置。

 

总结:

1、重新安装:yum install –y vsftpd

2、关闭防火墙和SELinux

永久关闭防火墙:

关闭: chkconfig iptables off

开启: chkconfig iptables on

3、永久关闭SELinux:

vi /etc/selinux/config

修改SELINUX=disabled

4、关闭可能影响ftp的防火墙策略

service iptables status    #查看防火墙

iptables -D INPUT 4          #删除与ftp有关的策略

5、重启系统,重启服务

6、注释userlist选项

7、创建虚拟用户口令文件

vi /etc/vsftpd/vuser.txt

里面写入奇数行用户名,偶数行密码

8、生成虚拟用户口令认证文件

db_load -T -t hash -f /etc/vsftpd/vuser.txt  /etc/vsftpd/vuser.db

9、编辑vsftp的PAM文件

注释掉里面所有的内容

输入一下两行

auth required /lib/security/pam_userdb.so db=/etc/vsftpd/vuser

account required /lib/security/pam_userdb.so db=/etc/vsftpd/vuser

10、建立本地映射用户并设置宿主目录权限

useradd -d /home/vftproot -s /sbin/nologin vuser

chmod 775 /home/vftproot/

11、修改配置文件

添加和开启以下三个选项

guest_enable=YES

guest_username=vuser

pam_service_name=vsftpd

12、重启vsftpd服务,并测试

13、调整虚拟用户权限

注:还是没有登录成功,实在是找不到错在了哪里。(后面再做做,如果能成功会再记录一下)

Guess you like

Origin www.cnblogs.com/Yuuki-/p/11957861.html