How do I check (in shell) whether I have a valid Kerberos ticket for a specific service?

醉酒当歌 提交于 2020-12-05 09:13:12

问题


I would like to be able to check (in my bash script) whether I have a valid unexpired ticket for a specific service. I can get this information by hand if I do klist, but it would be a bit of work to programmatically parse the expiration time, service principals, etc. Is there an easier way to do this? Thanks.


回答1:


Try klist -s, which should return a status code of 0 if you have a valid ticker, or 1 if not. You can then test that by looking at $?. For example:

if ! klist -s
then
    echo "kerberos ticket not valid; please run kinit"
    exit 1
fi


来源:https://stackoverflow.com/questions/45678787/how-do-i-check-in-shell-whether-i-have-a-valid-kerberos-ticket-for-a-specific

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!