Kerberose,使用ssh隧道获取票证



所以我必须使用kinit的keytab在本地作为某个主体。

由于远程服务器上的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端口侦听,这可能是个问题吗?

我使用socatssh解决了这个问题,如下所示,还有几个教程:

我们收到了到1088的udp包,但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

您可以强制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

最新更新