问题
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