Kerberos Extras for OS X

如果在mac上使用kerberos遇到了问题,可以考虑安装 Kerberos Extras.

对于我,我通过kinit成功获取到了票据,但连接到服务端时仍提示让我输入密码。 使用票据的话是不需再输入密码的,那么是没使用到票据,或者票据有问题。

ssh连接会使用几种验证方式(PreferredAuthentications),通过man ssh_config,搜索PreferredAuthentications可以看到ssh使用的几种验证方式,且按顺序逐一尝试,默认是:

gssapi-with-mic,hostbased,publickey,keyboard-interactive,password

可以在配置文件/etc/ssh_config中增加配置项来调整尝试的方式、顺序,或者减少验证方式。

PreferredAuthentications: gssapi-with-mic,hostbased,publickey,keyboard-interactive,password

从默认值可以看出,第一个尝试的方式就是查找票据。 通过ssh -v打开更多信息输出,可以看到报错,找不到票据,最后使用了password验证的方式,提示输入密码。问题看起来是,能获取到票据,但无法使用到该票据。 它做了两个事情:

在网上找到解决方法,安装Kerberos Extras,让kerberos支持基于CFM(Code Fragment Manager)的程序。

  1. 安装Kerberos CFM support library
  2. 把/System/Library/CoreSevices/票据显示程序.app链接为/Applications/Utilities/Ticket Viewer.app

提示: 安装时注意有一个步骤,选择「自定义」,不要安装MIT自家的配置文件edu.mit.Kerberos

好啦,主要是步骤一,那些还在使用CFM的程序们就能够正确使用到kerberos,这时就能无密码连接了,在服务器端执行klist也能看到带上来的票据,票据初始化的时间,跟当前ssh连接的时间点是一致的;返回到本地再klist也能看到本地保存有服务器端的票据,票据交换成功。

CFM和动态链接dyld是Mac os x上的两种运行时环境(Runtime Environment),摘录如下:

CFM determines addresses for referenced symbols in executables at build time (a static approach). The executable format used is called PEF (Preferred Executable Format). dyld resolves undefined symbols at execution time. The executable format is Mach-O (Mach object-file-format).

看起来CFM有点像静态链接,未深究。



额外的话题,每次本地kinit时要输入密码,可以把密码保存到keychain中,kinit username时直接回车就可以了。

security add-generic-password -a "xiaojie.zhang1" -l "XXX.OPI.COM (your_user_name)" -s "xxx.OPI.COM" -w “your_passwd" -T "/usr/bin/kinit”

具体用法,man security,再找到add-generic-password的各个参数。

add-generic-password [-h] [-a account] [-s service] [-w password] [options...] [keychain]
    Add a generic password item.

    -a account      Specify account name (required)
    -c creator      Specify item creator (optional four-character code)
    -C type         Specify item type (optional four-character code)
    -D kind         Specify kind (default is "application password")
    -G value        Specify generic attribute value (optional)
    -j comment      Specify comment string (optional)
    -l label        Specify label (if omitted, service name is used as default label)
    -s service      Specify service name (required)
    -p password     Specify password to be added (legacy option, equivalent to -w)
    -w password     Specify password to be added
    -A              Allow any application to access this item without warning (insecure, not recommended!)
    -T appPath      Specify an application which may access this item (multiple -T options are allowed)
    -U              Update item if it already exists (if omitted, the item cannot already exist)



票据会过期,过期后重新kinit,但tmux的session不会自动加载这个新的票据。

to be continue…



– EOF –

Categories: mac
Tags: kerberos,mac