如何检查(在Shell中)对于特定服务我是否具有有效的Kerberos票证? [英] How do I check (in shell) whether I have a valid Kerberos ticket for a specific service?
本文介绍了如何检查(在Shell中)对于特定服务我是否具有有效的Kerberos票证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望能够(在我的bash
脚本中)检查我是否具有针对特定服务的有效未过期票证.如果执行klist
,我可以手工获取此信息,但是以编程方式解析到期时间,服务主体等会有些工作.是否有更简单的方法来执行此操作?谢谢.
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.
推荐答案
尝试klist -s
,如果您有有效的股票行情代码,则应返回状态代码0
,否则返回状态代码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
这篇关于如何检查(在Shell中)对于特定服务我是否具有有效的Kerberos票证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文