【问题标题】:Kerberose, get ticket using ssh tunnelingKerberos,使用 ssh 隧道获取票证
【发布时间】:2017-08-31 09:45:32
【问题描述】:

所以我必须在本地使用他的密钥表将kinit 作为某个委托人。

由于远程服务器上的 Kerberose kdc,我通过 vpn 访问,我需要使用 ssh 访问服务器,从而建立到服务的隧道。

为此,我做了以下工作:

  1. 从远程服务器复制 krb5.conf 并用它替换本地
  2. 复制了我感兴趣的 keytab
  3. 因为我需要访问服务:

    ssh -L1088:localhost:88 -L10749:localhost:749 remote_server
    
  4. 将本地文件 krb5.conf 更改为

    admin_server = localhost:10749
    kdc = localhost:1088
    

但是当我尝试启动时

KRB5_TRACE=/dev/stdout kinit -kt ${PRINCIPAL_KEYTAB}.keytab ${PRINCIPAL_NAME}
[12332] 1504171391.121253: Getting initial credentials for ${PRINCIPAL_NAME}
[12332] 1504171391.123940: Looked up etypes in keytab: des, des-cbc-crc, aes128-cts, rc4-hmac, aes256-cts, des3-cbc-sha1                                                                                                                
[12332] 1504171391.124027: Sending request (227 bytes) to ${DOMAIN}                                  
[12332] 1504171391.124613: Resolving hostname localhost                                                             
[12332] 1504171391.124988: Sending initial UDP request to dgram ::1:1088                                            
[12332] 1504171391.125070: Sending initial UDP request to dgram 127.0.0.1:1088                                      
[12332] 1504171391.125120: Initiating TCP connection to stream ::1:1088                                             
[12332] 1504171391.125165: Terminating TCP connection to stream ::1:1088                                            
[12332] 1504171391.125186: Initiating TCP connection to stream 127.0.0.1:1088                                       
[12332] 1504171391.125216: Terminating TCP connection to stream 127.0.0.1:1088                                      
kinit: Cannot contact any KDC for realm '${DOMAIN}' while getting initial credentials
  1. 我通过添加ssh -vvv 重试并得到了

    debug1: Connection to port 1088 forwarding to localhost port 88 requested.
    debug2: fd 15 setting TCP_NODELAY
    debug2: fd 15 setting O_NONBLOCK
    debug3: fd 15 is O_NONBLOCK
    debug1: channel 7: new [direct-tcpip]
    debug3: send packet: type 90
    debug1: Connection to port 1088 forwarding to localhost port 88 requested.
    debug2: fd 16 setting TCP_NODELAY
    debug2: fd 16 setting O_NONBLOCK
    debug3: fd 16 is O_NONBLOCK
    debug1: channel 8: new [direct-tcpip]
    debug3: send packet: type 90
    

我尝试了 tcpdump,并且本地尝试连接,但找不到任何接收到其他站点的包。

我编辑了 krb5.conf 中的所有其他信息。

我在这里缺少什么或者这可能吗?

PS: netstat 表示端口在两台机器上都存在并打开。 我对服务器本身的kinit 没有任何问题。

PSS: 从我看到的kdc实际上是在端口udp 88而不是tcp上监听,这可能是个问题吗?

【问题讨论】:

    标签: ssh kerberos


    【解决方案1】:

    我毕竟通过使用socatssh解决了它,如下所示,以及几个教程:

    我们正在接收 udp 到 1088 的包,但 ssh 仅隧道 tcp,因此使用 socat 我们可以“转换”它们:

    locally$ socat -T15 udp4-recvfrom:1088,reuseaddr,fork tcp:localhost:1089
    

    现在我们创建该端口到远程服务器的 ssh 隧道

    locally$ ssh -L1089:localhost:1089 remote_server
    

    之后,我们将到达 1089 的 tcp 包转换为 udp 并将它们重定向到端口 88 的 kdc vie

    server$ socat tcp4-listen:1088,reuseaddr,fork UDP:localhost:88
    

    【讨论】:

      【解决方案2】:

      您可以强制 kerberos 仅使用 tcp,而不必同时传输 UDP 流量,如下所示:

      [realms]
       MY.REALM = {
        kdc = tcp/localhost:1088
        master_kdc = tcp/localhost:1088
        admin_server = tcp/localhost:1749
       }
      

      现在像以前一样设置您的 tcp/ssh 隧道:

      ssh -L1088:kdc.server:88 -L1749:kdc.server:749 ssh.hop
      

      【讨论】:

      • 如果你指的是tcp/localhost:1088上的kdc,隧道不应该在本地映射到1088吗?如ssh -L1088:kdc.server:88 [...]
      • @steen 你是对的(其他端口也一样)。更正了我原来的回复。
      猜你喜欢
      • 2013-12-07
      • 1970-01-01
      • 2021-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-20
      • 2019-08-07
      • 1970-01-01
      相关资源
      最近更新 更多