AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 66556
Accepted
Harley
Harley
Asked: 2009-09-18 21:58:06 +0800 CST2009-09-18 21:58:06 +0800 CST 2009-09-18 21:58:06 +0800 CST

让 Squid 使用 kerberos 和 Windows 2008/2003/7/XP 进行身份验证

  • 772

这是我最近设置的东西,非常痛苦。我的环境变得越来越好,可以在不可见的情况下针对 Windows 2008 Server 对 Windows 7 客户端进行身份验证。NTLM 并不是一个真正的选项,因为使用它需要在每个客户端上更改注册表。

自 Windows 2000 以来,MS 一直在推荐 Kerberos,所以现在是时候使用该程序了。

非常感谢 Squid 邮件列表的 Markus Moeller 帮助完成这项工作。

windows-server-2008
  • 3 3 个回答
  • 47066 Views

3 个回答

  • Voted
  1. Best Answer
    Harley
    2009-09-18T22:01:15+08:002009-09-18T22:01:15+08:00

    这是使用 Squid 3.0 设置的,也已经使用 Squid 3.1 进行了测试,应该可以与 Squid 2.7 一起使用。您的 Windows 用户必须是 Active Directory 中 SQUID_USERS 组的成员(无论如何,对于这种情况)。

    在 Windows 方面,Windows XP 和 Windows 2007 已经针对 Windows 2008 进行了测试,Windows XP 针对 Windows 2003 进行了测试。

    请注意,几乎每一步都需要前一个步骤才能继续。

    如果您有问题,DNS始终是第一个查看的地方。两台 Windows 机器都应该能够按名称 ping Linux 服务器(反之亦然),而且您ipconfig /flushdns有时可能需要运行。如果您想真正确定没有任何问题,重新启动也可能会有所帮助。

    域名信息

    • Windows 域:dom.local
    • 域服务器:server.dom.local,172.17.3.11
    • CentOS 鱿鱼服务器:centos.dom.local,172.17.3.10

    域服务器设置

    1. 在 DNS 配置中创建dom.local反向区域。
    2. 创建centos.dom.local指向的静态 ('A') 记录,当询问您是否也设置反向 PTR 时172.17.3.10选择是。

    视窗 2008

    对于 Windows 2008 服务器,您需要安装Hotfix 951191。

    Linux 设置

    小包

    安装包

    $ yum install -y cyrus-sasl-gssapi cvs autoconf automake openldap openldap-devel krb5-workstation krb5-devel gcc-c++
    

    安装msktutil. 您需要在构建它之前对其进行修补。

    $ wget http://download.systemimager.org/~finley/msktutil/msktutil_0.3.16.orig.tar.gz
    $ wget http://download.systemimager.org/~finley/msktutil/msktutil_0.3.16-7.diff.gz
    $ gunzip msktutil_0.3.16-7.diff.gz
    $ tar zxf msktutil_0.3.16.orig.tar.gz
    $ cd msktutil-0.3.16
    $ patch < ../msktutil_0.3.16-7.diff
    $ ./configure && make && make install
    

    编译最新的鱿鱼_遏制_ldap。

    $ cvs -z3 -d:pserver:[email protected]:/cvsroot/squidkerbauth co -P squid_kerb_ldap
    $ cd squid_kerb_ldap
    $ ./configure && make
    

    域名系统

    用于system-config-network配置指向域控制器的 DNS 点,将主机名设置为centos.dom.local.

    重启

    检查反向 DNS 是否正常工作:$ dig -x 172.17.3.10

    你应该进入centos.dom.local答案部分。如果你不这样做,那么继续下去是没有意义的。如果没有正确配置 DNS,Kerberos 身份验证将无法工作。

    Kerberos

    你krb.conf应该看起来像这样:

    [logging]
     default = FILE:/var/log/krb5libs.log
     kdc = FILE:/var/log/krb5kdc.log
     admin_server = FILE:/var/log/kadmind.log
    
    [libdefaults]
     default_realm = DOM.LOCAL
     dns_lookup_realm = false
     dns_lookup_kdc = false
     ticket_lifetime = 24h
    
    # For Windows XP:
     default_tgs_enctypes = rc4-hmac des-cbc-crc des-cbc-md5
     default_tkt_enctypes = rc4-hmac des-cbc-crc des-cbc-md5
     permitted_enctypes = rc4-hmac des-cbc-crc des-cbc-md5
    
    # For Windows 2007:
    # default_tgs_enctypes = aes256-cts-hmac-sha1-96 rc4-hmac des-cbc-crc des-cbc-md5
    # default_tkt_enctypes = aes256-cts-hmac-sha1-96 rc4-hmac des-cbc-crc des-cbc-md5
    # permitted_enctypes = aes256-cts-hmac-sha1-96 rc4-hmac des-cbc-crc des-cbc-md5
     forwardable = yes
    
    [realms]
     DOM.LOCAL = {
      kdc = 172.17.3.11:88
      admin_server = 172.17.3.11:7491
      default_domain = dom.local
     }
    
    [domain_realm]
     .dom.local = DOM.LOCAL
     dom.local = DOM.LOCAL
    
    [appdefaults]
     pam = {
       debug = false
       ticket_lifetime = 36000
       renew_lifetime = 36000
       forwardable = true
       krb4_convert = false
    }
    

    创建密钥表:

    $ kinit administrator
    $ msktutil -c -b "CN=COMPUTERS" -s HTTP/centos.dom.local -h centos.dom.local -k /etc/HTTP.keytab --computer-name centos-http --upn HTTP/centos.dom.local --server server.dom.local --verbose
    

    对于 Windows 2008,您需要添加--enctypes 28到msktutil命令中。

    乌贼

    安装鱿鱼:

    $ wget http://www.squid-cache.org/Versions/v3/3.0/squid-3.0.STABLE18.tar.gz
    $ tar zxvf squid-3.0.STABLE18.tar.gz 
    $ cd squid-3.0.STABLE18
    $ ./configure --enable-negotiate-auth-helpers=squid_kerb_auth --enable-stacktraces --prefix=/opt/squid-3.0
    $ make
    $ make install
    $ cp helpers/negotiate_auth/squid_kerb_auth/squid_kerb_auth /opt/squid-3.0/sbin/
    $ cp ~/squid_kerb_ldap/squid_kerb_ldap /opt/squid-3.0/sbin/
    $ cd /opt/squid-3.0/
    $ mv etc/squid.conf etc/squid.conf.ORIG
    

    在 squid.conf 中设置适当的参数:

    auth_param negotiate program /opt/squid-3.0/sbin/squid_kerb_auth -d -s HTTP/centos.dom.local
    auth_param negotiate children 10
    auth_param negotiate keep_alive o
    
    external_acl_type SQUID_KERB_LDAP ttl=3600  negative_ttl=3600  %LOGIN /opt/squid-3.0/sbin/squid_kerb_ldap -d -g SQUID_USERS
    acl AUTHENTICATED proxy_auth REQUIRED
    acl LDAP_GROUP_CHECK external SQUID_KERB_LDAP
    acl localnet src 172.17.3.0/24        # RFC1918 possible internal network
    
    #http_access allow localnet
    #http_access allow AUTHENTICATED
    http_access allow LDAP_GROUP_CHECK
    
    cache_dir ufs /var/cache/squid-3.0 100 16 256
    access_log /var/log/squid-3.0/access.log squid
    cache_log /var/log/squid-3.0/cache.log
    cache_store_log /var/log/squid-3.0/store.log
    pid_filename /var/run/squid-3.0.pid
    cache_effective_user squid
    cache_effective_group squid
    coredump_dir /var/cache/squid-3.0
    

    设置用户和目录:

    $ chown -R squid:squid /opt/squid-3.0/
    $ mkdir /var/cache/squid-3.0
    $ chown -R squid:squid /var/cache/
    $ mkdir /var/log/squid-3.0
    $ chown -R squid:squid /var/log/squid-3.0/
    $ chown squid:squid /etc/HTTP.keytab
    

    创建缓存:

    $ /opt/squid-3.0/sbin/squid -z
    

    初始化脚本

    现在这很重要:Squid 需要设置一些环境变量才能正常运行。最好的方法是使用初始化脚本。这是一个稍微编辑过的 CentOS:

    #!/bin/bash
    # squid     This shell script takes care of starting and stopping
    #       Squid Internet Object Cache
    #
    # chkconfig: - 90 25
    # description: Squid - Internet Object Cache. Internet object caching is \
    #   a way to store requested Internet objects (i.e., data available \
    #   via the HTTP, FTP, and gopher protocols) on a system closer to the \
    #   requesting site than to the source. Web browsers can then use the \
    #   local Squid cache as a proxy HTTP server, reducing access time as \
    #   well as bandwidth consumption.
    # pidfile: /var/run/squid-3.0.pid
    # config: /opt/squid-3.0/etc/squid.conf
    
    PATH=/usr/bin:/sbin:/bin:/usr/sbin
    export PATH
    
    # Source function library.
    . /etc/rc.d/init.d/functions
    
    # Source networking configuration.
    . /etc/sysconfig/network
    
    # don't raise an error if the config file is incomplete
    # set defaults instead:
    SQUID_OPTS=${SQUID_OPTS:-"-D"}
    SQUID_PIDFILE_TIMEOUT=${SQUID_PIDFILE_TIMEOUT:-20}
    SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-100}
    
    KRB5_KTNAME=/etc/HTTP.keytab
    export KRB5_KTNAME
    
    # determine the name of the squid binary
    [ -f /opt/squid-3.0/sbin/squid ] && SQUID=/opt/squid-3.0/sbin/squid
    
    prog="$SQUID"
    
    # determine which one is the cache_swap directory
    CACHE_SWAP=`sed -e 's/#.*//g' /opt/squid-3.0/etc/squid.conf | \
        grep cache_dir |  awk '{ print $3 }'`
    [ -z "$CACHE_SWAP" ] && CACHE_SWAP=/var/spool/squid-3.0
    
    RETVAL=0
    
    start() {
    
            #check if the squid conf file is present
            if [ ! -f /opt/squid-3.0/etc/squid.conf ]; then
                echo "Configuration file /opt/squid-3.0/etc/squid.conf missing" 1>&2
                exit 6
            fi
            . /etc/sysconfig/squid
    
            # don't raise an error if the config file is incomplete.
            # set defaults instead:
            SQUID_OPTS=${SQUID_OPTS:-"-D"}
            SQUID_PIDFILE_TIMEOUT=${SQUID_PIDFILE_TIMEOUT:-20}
            SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-100}
    
            if [ -z "$SQUID" ]; then
                    echo "Insufficient privilege" 1>&2
                    exit 4
            fi
    
            for adir in $CACHE_SWAP; do
            if [ ! -d $adir/00 ]; then
             echo -n "init_cache_dir $adir... "
             $SQUID -z -F -D >> /var/log/squid-3.0/squid.out 2>&1
        fi
        done
        echo -n $"Starting $prog: "
        $SQUID $SQUID_OPTS >> /var/log/squid-3.0/squid.out 2>&1
        RETVAL=$?
        if [ $RETVAL -eq 0 ]; then
           timeout=0;
           while : ; do
              [ ! -f /var/run/squid-3.0.pid ] || break
          if [ $timeout -ge $SQUID_PIDFILE_TIMEOUT ]; then
             RETVAL=1
             break
          fi
          sleep 1 && echo -n "."
          timeout=$((timeout+1))
           done
        fi
        [ $RETVAL -eq 0 ] && touch /var/lock/subsys/squid-3.0
        [ $RETVAL -eq 0 ] && echo_success
        [ $RETVAL -ne 0 ] && echo_failure
        echo
        return $RETVAL
    }
    
    stop() {
        . /etc/sysconfig/squid
    
        # don't raise an error if the config file is incomplete.
        # set defaults instead:
        SQUID_SHUTDOWN_TIMEOUT=${SQUID_SHUTDOWN_TIMEOUT:-100}
    
        echo -n  $"Stopping $prog: "
        $SQUID -k check >> /var/log/squid-3.0/squid.out 2>&1
        RETVAL=$?
        if [ $RETVAL -eq 0 ] ; then
            $SQUID -k shutdown &
            rm -f /var/lock/subsys/squid-3.0
        timeout=0
        while : ; do
            [ -f /var/run/squid-3.0.pid ] || break
            if [ $timeout -ge $SQUID_SHUTDOWN_TIMEOUT ]; then
                echo
                return 1
            fi
            sleep 2 && echo -n "."
            timeout=$((timeout+2))
            done
        echo_success
        echo
        else
            echo_failure
        echo
        fi
        return $RETVAL
    }
    
    reload() {
        . /etc/sysconfig/squid
        # don't raise an error if the config file is incomplete.
        # set defaults instead:
        SQUID_OPTS=${SQUID_OPTS:-"-D"}
    
        $SQUID $SQUID_OPTS -k reconfigure
    }
    
    restart() {
        stop
        start
    }
    
    condrestart() {
        [ -e /var/lock/subsys/squid-3.0 ] && restart || :
    }
    
    rhstatus() {
        status $SQUID && $SQUID -k check
    }
    
    probe() {
        return 0
    }
    
    case "$1" in
    start)
        start
        ;;
    
    stop)
        stop
        ;;
    
    reload)
        reload
        ;;
    
    restart)
        restart
        ;;
    
    condrestart)
        condrestart
        ;;
    
    status)
        rhstatus
        ;;
    
    probe)
        exit 0
        ;;
    
    *)
        echo $"Usage: $0 {start|stop|status|reload|restart|condrestart}"
        exit 2
    esac
    
    exit $?
    

    这些是重要的行:

    KRB5_KTNAME=/etc/HTTP.keytab
    export KRB5_KTNAME
    

    客户端机器

    centos.dom.local使用 port将您的代理设置为服务器3128。使用完全限定域名而不是 IP 地址很重要。

    • 15
  2. Phil
    2009-11-21T18:05:17+08:002009-11-21T18:05:17+08:00

    而不是编辑 /etc/init.d/squid 来设置 KRB5_KTNAME 环境变量,你应该把这些行放在 /etc/sysconfig/squid 中。由于 init 脚本在每次执行时都使用 /etc/sysconfig/squid ,因此它会选择这两行。

    此外,您无需将主机明确命名为 KDC 和 kadmin 服务器,只需输入 Active Directory 域的 DNS 域即可。有两个原因:

    1. MIT Kerberos 和 Heimdal kerberos 都足够聪明,可以使用 Windows 客户端用来定位 KDC 和 kadmin 服务器的相同 SRV 记录
    2. DNS 域(在您的示例中为 dom.local)将返回指向您的域控制器的 A 记录
    • 1
  3. Chonzu
    2010-04-05T23:44:20+08:002010-04-05T23:44:20+08:00

    按照这个tuto,我可以让squid在fedora 12服务器上工作。检查 Linux 服务器上的防火墙(启用端口 3128)并将 SELinux 设置为许可模式。

    • 0

相关问题

  • 文件复制到分支机构

  • 对于 ASP.Net 应用程序,Windows 64 位相对于 32 位的主要优势是什么?

  • Windows Server 2008 Hyper-V 虚拟化服务器的最佳 RAID 配置?

  • 远程连接 sql server 不工作,但如果防火墙禁用它呢?

  • 无法从 SQL Server 2008 备份数据库

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    从 IP 地址解析主机名

    • 8 个回答
  • Marko Smith

    如何按大小对 du -h 输出进行排序

    • 30 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    Windows 中执行反向 DNS 查找的命令行实用程序是什么?

    • 14 个回答
  • Marko Smith

    如何检查 Windows 机器上的端口是否被阻塞?

    • 4 个回答
  • Marko Smith

    我应该打开哪个端口以允许远程桌面?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    MikeN 在 Nginx 中,如何在维护子域的同时将所有 http 请求重写为 https? 2009-09-22 06:04:43 +0800 CST
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    0x89 bash中的双方括号和单方括号有什么区别? 2009-08-10 13:11:51 +0800 CST
  • Martin Hope
    kch 如何更改我的私钥密码? 2009-08-06 21:37:57 +0800 CST
  • Martin Hope
    Kyle Brandt IPv4 子网如何工作? 2009-08-05 06:05:31 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve