• 【kerberos】使用 curl 访问受 Kerberos HTTP SPNEGO 保护的 URL


    前言:

    大数据集群集成 Kerberos 后,很多 WEBUI 打开都会提示输入用户名和密码。由于我想获取 flink 任务的详情,且KNOX 并不支持Flink api,查看KNOX 直接的列表:https://docs.cloudera.com/cdp-private-cloud-base/7.1.7/knox-authentication/topics/security-knox-supported-services-matrix.html。所以只能是直接请求由 kerberos 保护的rest 地址了。

    这里介绍如何使用 curl 命令行的方式来访问受 Kerberos HTTP SPNEGO 保护的 URL。

    在这里插入图片描述

    前提:

    1. curl 版本需支持 GSS-Negotiate
    2. keytab 文件或者 kerberos 用户/密码
    3. curl -u 参数不可省略,但是username/password 可以省略

    具体步骤:

    1. 要访问受 Kerberos HTTP SPNEGO 保护的 URL,请确保您的 版本支持 GSS 并且能够运行 。
    curl -V
    curl 7.19.7 (universal-apple-darwin10.0) libcurl/7.19.7 OpenSSL/0.9.8l
    zlib/1.2.3
    Protocols: tftp ftp telnet dict ldap http file https ftps
    Features: GSS-Negotiate IPv6 Largefile NTLM SSL libz
    
    • 1
    • 2
    • 3
    • 4
    • 5
    1. 使用 kinit 登录到 KDC。
    kinit /opt/keytab/test.keytab test
    
    或者
    kinit
    Please enter the password for username@LOCALHOST:
    
    • 1
    • 2
    • 3
    • 4
    • 5
    1. 使用 curl 获取受保护的 URL。

    我这里是调用的 flink on yarn 程序累加器的rest 请求。

    curl --negotiate -u :  http://1.1.1.1:8088/proxy/application 1694747643798_0956/jobs/c88ce26450f1f9dc6423eeodec31ada7/accumulators
    
    • 1
    • –negotiate 在curl 中开启 SPNEGO
    • -u 该选项是必需的,但用户名和密码可以省略

    参考:

    • https://docs.cloudera.com/runtime/7.2.0/scaling-namespaces/topics/hdfs-curl-url-http-spnego.html
    • https://hadoop.apache.org/docs/current/hadoop-hdfs-httpfs/UsingHttpTools.html
  • 相关阅读:
    《人间失格》阅读笔记
    5G投资下降,遥遥领先的主流5G或被运营商抛弃,“假5G”更获青睐
    天池Python练习07-字符串
    基于嵌入式Qt 开发板蜂鸣器(BEEP)
    这是一代骄马
    记一次 Android 周期性句柄泄漏的排查
    已解决Python爬虫报错<Response [403]>
    41. set()函数:将可迭代对象转换为可变集合
    Python面试题:请解释 `__slots__` 的作用
    小程序实现下拉刷新
  • 原文地址:https://blog.csdn.net/Mrerlou/article/details/134437427