4

I use MIT ktutil a lot on Linux and I am fed up using the following sequence, even if command shortcuts and file name completion are here to help:

ktutil
rkt my.keytab
l

Isn't there a way to get the same result in a "one-line" way from the shell? Either with an alias, a function, or just with another tool?

2

I always use klist instead to list the contents of keytab files out instead of ktutil.

Example #1 - klist

$ klist -kt /etc/somedir/conf/some.keytab
Keytab name: FILE:/etc/somedir/conf/some.keytab
KVNO Timestamp         Principal
---- ----------------- --------------------------------------------------------
   5 08/25/15 11:18:35 app/host1.dom.local@TD.COM
   5 08/25/15 11:18:35 app/host1.dom.local@TD.COM
   5 08/25/15 11:18:35 app/host1.dom.local@TD.COM
   7 08/25/15 11:18:35 app/host2.dom.local@TD.COM
...

Example #2 - process substitution

You can also use a redirect to ktutil's STDIN like so:

$ ktutil < <(echo -e "rkt /etc/somedir/conf/some.keytab\nlist")
ktutil:  rkt /etc/somedir/conf/some.keytab
ktutil:  list
slot KVNO Principal
---- ---- ---------------------------------------------------------------------
   1    5 app/host1.dom.local@TD.COM
   2    5 app/host1.dom.local@TD.COM
   3    5 app/host1.dom.local@TD.COM
   4    7 app/host1.dom.local@TD.COM
0

I found a way with a shell function, after guessing ktutil may accept commands from stdin:

rkt() { echo -e "read_kt $1\nlist\nquit" | ktutil | grep -v "^ktutil:"; }

And invoke with rkt my.keytab

Works as far as file name contains no space.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.