zoukankan      html  css  js  c++  java
  • Linux服务器配置---ftp用户黑名单

    用户黑白名单

          一个Linux主机中会多个用户,而我们希望有些用户不能去访问ftp。ftp服务器可以通过配置文件“/etc/vsftpd/user_list”来设置一个用户列表,这个列表可以是黑名单,也可以是白名单,具体要根据配置文件的参数“userlist_deny”来确定

    1、黑名单

          1)修改配置文件“/etc/vsftpd/vsftpd.conf”中的参数“userlist_enable”,确保这个参数是yes

    [root@localhost wj]# gedit /etc/vsftpd/vsftpd.conf        //匿名登录

    userlist_enable=YES

          2)打开配置文件“/etc/vsftpd/vsftpd.conf“,在末尾追加一句话”userlist_deny=yes“。这个参数是yes,表示要设置一个黑名单

    [root@localhost wj]# lftp david:543092@192.168.0.113:8765    //用户david登录,密码是543092

    userlist_deny=YES

          3)编辑文件“/etc/vsftpd/user_list“,在末尾追加一句话要设置的用户名即可

    [root@localhost ~]#gedit /etc/vsftpd/user_list

    # vsftpd userlist

    # If userlist_deny=NO, only allow users in this file

    # If userlist_deny=YES (default), never allow users in this file, and

    # do not even prompt for a password.

    # Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers

    # for users that are denied.

    root

    bin

    daemon

    adm

    lp

    sync

    shutdown

    halt

    mail

    news

    uucp

    operator

    games

    nobody

    david

          4)重启服务,测试黑名单内的用户是否可以访问,上面列出的都是不可以访问的用户

    [root@localhost wj]# service vsftpd restart        //重启服务

    关闭vsftpd                                             [失败]

     vsftpd 启动vsftpd                                    [确定]

     

    [root@localhost wj]# lftp weijie:123456@192.168.0.113:8765     //用户weijie登录,可以访问

    lftp weijie@192.168.0.113:~> ls

    -rwxrwxrwx    1 0        0        2375494044 Aug 14 07:13 1.zip

    lftp weijie@192.168.0.113:~> bye

     

    [root@localhost wj]# lftp 192.168.0.113:8765                //匿名用户也可以

    lftp 192.168.0.113:~> ls

    drwxr-xr-x    2 0        0            4096 Aug 14 06:38 pub

    lftp 192.168.0.113:/> 

     

    [root@localhost wj]# lftp david:543092@192.168.0.113:8765    //用户david在黑名单中,因此无法访问,ls命令会失败

    lftp david@192.168.0.113:~> ls

    [0] ls &                                 

        `ls' at 0 [重新连接前延时: 28]

    lftp david@192.168.0.113:~>

     

    2、白名单

          1)修改配置文件“/etc/vsftpd/vsftpd.conf”中的参数“userlist_enable”,确保这个参数是yes

    [root@localhost wj]# gedit /etc/vsftpd/vsftpd.conf        //匿名登录

    userlist_enable=YES

          2)打开配置文件“/etc/vsftpd/vsftpd.conf“,在末尾追加一句话”userlist_deny=NO“。这个参数是NO,表示要设置一个白名单

    [root@localhost wj]# lftp david:543092@192.168.0.113:8765    //用户david登录,密码是543092

    userlist_deny=NO

          3)编辑文件“/etc/vsftpd/user_list“,在末尾追加一句话要设置的用户名即可

    [root@localhost ~]#gedit /etc/vsftpd/user_list

    # vsftpd userlist

    # If userlist_deny=NO, only allow users in this file

    # If userlist_deny=YES (default), never allow users in this file, and

    # do not even prompt for a password.

    # Note that the default vsftpd pam config also checks /etc/vsftpd/ftpusers

    # for users that are denied.

    root

    bin

    daemon

    adm

    lp

    sync

    shutdown

    halt

    mail

    news

    uucp

    operator

    games

    nobody

    david

          4)重启服务,测试黑名单内的用户是否可以访问,上面列出的都是不可以访问的用户

    [root@localhost wj]# service vsftpd restart        //重启服务

    关闭vsftpd                                             [失败]

     vsftpd 启动vsftpd                                    [确定]

     

    [root@localhost wj]# lftp david:543092@192.168.0.113:8765     //用户david登录,可以访问

    lftp weijie@192.168.0.113:~> ls

    -rwxrwxrwx    1 0        0        2375494044 Aug 14 07:13 1.zip

    lftp weijie@192.168.0.113:~> bye

     

    [root@localhost wj]# lftp weijie:123456@192.168.0.113:8765    //用户weijie不在白名单中,因此无法访问,ls命令会失败

    lftp david@192.168.0.113:~> ls

    [0] ls &                                 

        `ls' at 0 [重新连接前延时: 28]

    lftp david@192.168.0.113:~> bye

     

    [root@localhost wj]# lftp 192.168.0.113:8765         //匿名用户也不行

    lftp 192.168.0.113:~> ls

    [0] ls &                                 

        `ls' at 0 [重新连接前延时: 28]

    lftp 192.168.0.113:~> 

     

     

     做了一个Linux学习的平台,目前出来一个雏形,各位可以参考使用
    链接:https://pan.baidu.com/s/1GOLVU2CbpBNGtunztVpaCQ  密码:n7bk

  • 相关阅读:
    字段与表的对应关系
    java初学代码,还不太熟练
    编程学习心得
    ps中经常遇到的问题
    R语言矩阵运算加速
    写代码过程中一些数字推理公式
    EXCEL中常用的函数
    css样式中常见的属性
    R语言的基本矩阵运算
    excel常用的函数
  • 原文地址:https://www.cnblogs.com/wj78080458/p/10030117.html
Copyright © 2011-2022 走看看