KRENEW(1)
π NAME π
krenew β renew a Kerberos ticket, bestie. that's it, that's the whole vibe check. this page lives in the kstart manual, section 1. β¨
π SYNOPSIS π
krenew [-abhiLstvx] [-c child pid file] [-H minutes]
[-K minutes] [-k ticket cache] [-p pid file]
[command ...]
π¦ DESCRIPTION π¦
okay so. krenew renews an existing renewable ticket. like, it takes your ticket and gives it a lil glow-up so it stays valid. π
Run it with zero arguments and it just tries to renew the existing ticket-granting ticket in the current ticket cache β that's literally equivalent to kinit -R, no cap.
But it's also flexible like that:
- it can optionally run a program like
aklogto refresh AFS tokens πΈ - it can run as a daemon and wake up periodically to renew the ticket cache β°
- it can run a specified command and keep renewing the ticket cache until the command finishes (or until renewal is simply no longer possible) π«Ά
If a command is specified, krenew by default wakes up every 60 minutes (1 hour) to check the ticket cache. that's the default, periodt.
π the private ticket cache thing (so important)
If a command is given, krenew makes a copy of the ticket cache and creates a private ticket cache just for that command. why? to isolate it from later destruction of the original ticket cache, obviously. π
This is what lets krenew maintain authentication for a command even if, say, the user running the command logs out and OpenSSH destroys their original ticket cache. iconic protective energy honestly. π
π shell stuff, listen up
If a command is given, it will not be run using the shell. so if you want to use shell metacharacters in the command with their special meaning, give sh -c command as the command to run, and quote command. π (yes this trips people up constantly)
And if the command contains command-line options (like -c), put -- on the command line before the beginning of the command, so krenew knows not to parse those options as its own. iykyk. π
π PAG + AFS tokens
If krenew is built with setpag() support and AFS tokens are requested with the -t option, it will put the command in a separate PAG before obtaining AFS tokens β so they don't interfere with other processes on the system. considerate fr fr. π§
π‘ signals, aka the main character energy
When running a command, krenew propagates HUP, TERM, INT, and QUIT signals to the child process and does not exit when those signals are received. (tho if the propagated signal causes the child process to exit, krenew will then exit.) π
Why does this matter? Because it lets krenew react properly when run under a command supervision system such as runit(8) or svscan(8) β systems that use signals to control supervised commands β and it lets you run interactive commands that should receive Ctrl-C. π₯
and if a running krenew receives an ALRM signal, it immediately refreshes the ticket cache regardless of whether it is in danger of expiring. instant. no waiting. slay. β¨
to be continued, bestie β more sections coming π
β¨ OPTIONS β¨
-aβ bestie, this one is about always renewing, no chill. When you run with either the-Kflag or a command, this makeskrenewrenew tickets every single time it wakes up. Without it,krenewis on its lazy-girl era and will only try to renew a ticket as often as it has to, just to keep it from expiring. With-a, it renews according to the interval you gave with-K.
This behavior probably should have been the default behavior of -K. The default wasn't changed because they didn't wanna mess with existing users, but for new applications, consider always using -a with -K. π
This option matters a LOT if another program is out here manipulating the ticket cache that krenew is using. Say another program is automatically renewing a ticket more often than krenew does β then krenew will never see a ticket that's close to expiring, so by default it will never try to renew the ticket. And that means krenew will also never renew AFS tokens, even if you gave the -t option, because krenew only renews AFS tokens after it successfully renews a ticket. If you specify this option in that kind of situation, krenew will renew its ticket every time it checks the ticket, so AFS tokens will get renewed. π«Ά
This argument is only valid in combination with either -K or a command to run.
-bβ after starting, detach from the controlling terminal and run in the background. This only makes sense in combination with-Kor a command thatkrenewwill be running.krenewwill not background itself until after it does the initial ticket renewal, so any initial errors will be reported, but then it redirects output to/dev/nulland no subsequent errors will be reported. π
If this flag is given, krenew will also change directories to "/". All paths (such as to a command to run or a PID file) should therefore be given as absolute, not relative, paths.
If you use it with a command to run, that command will also run in the background and will also have its input and output redirected to /dev/null. It will have to report any errors via some other mechanism for the errors to be seen.
Use of this flag on Mac OS X without specifying a file-based ticket cache by either using -k or setting KRB5CCNAME will probably not do what you want. Ticket caches on Mac OS X are, by default, per-session, and with -b krenew will detach itself from your existing ticket cache. Instead, to renew the default ticket cache on Mac OS X, try something like:
(krenew -K 60 &)
to run krenew in the background but within the current session.
When using this option, consider also using -L to report krenew errors to syslog.
-cchild pid file β save the process ID (PID) of the child process into child pid file. child pid file is created if it doesn't exist and overwritten if it does exist. This option is only allowed when a command was given on the command line, and it's most useful in conjunction with-bso you can actually manage the running child process.
Note that, when used with-b, the PID file is written out afterkrenewis backgrounded and changes its working directory to/, so relative paths for the PID file will be relative to/(probably not what you want). π
-Hminutes β only renew the ticket if it has a remaining lifetime of less than minutes minutes. If either the ticket already has a sufficiently long remaining lifetime or renewal was successful, run the command (if one was specified) or exit immediately with status0(if none was). Otherwise, try to renew the ticket so that it will have a remaining lifetime of at least minutes, exit with an error if unsuccessful, and then run the command, if any.
If -H is used with -K, krenew will not exit immediately. Instead, the specified remaining lifetime will replace the default value of two minutes, meaning krenew will ensure, each time it wakes up, that the ticket has a remaining lifetime of the minutes argument. This is an alternative to -a to ensure that tickets always have a certain minimal amount of lifetime remaining. β¨
-hβ display a usage message and exit. Short, sweet, iconic.-iβ ignore errors in renewing the ticket and keep running. Normally,krenewexits as soon as the ticket cache either disappears or the tickets run out of renewable lifetime. If this flag is given, it will complain about the failure to standard error (unless-bwas given) but continue running, waking up to try again after the next check interval (see-K). This is useful if some other process may recreate an expired ticket cache andkrenewshould stay around and act on that recreated ticket cache once it's present.
If the initial ticket cache renew fails, krenew will retry the renewal immediately and then with exponential backoff to once per minute, and keep trying until authentication succeeds or it is killed. The command, if any, will not be started until cache renewal succeeds.
This flag is only useful in daemon mode or when a command was given.
-Kminutes β run in daemon mode to keep a ticket alive indefinitely. The program reawakens after minutes minutes, checks if the ticket will expire before or less than two minutes before the next scheduled check, and renews the ticket if needed. (In other words, it ensures that the ticket will always have a remaining lifetime of at least two minutes.) If the-Hflag is also given, the lifetime specified by it replaces the two minute default.
If this option is not given but a command was given on the command line, the default interval is 60 minutes (1 hour).
If an error occurs in refreshing the ticket cache that doesn't cause krenew to exit, the wake-up interval will be shortened to one minute and the operation retried at that interval for as long as the error persists. π₯
-kticket cache β use ticket cache as the ticket cache rather than the contents of the environment variableKRB5CCNAMEor the library default. ticket cache may be any ticket cache identifier recognized by the underlying Kerberos libraries. This generally supports a path to a file, with or without a leading"FILE:"string, but may also support other ticket cache types.-Lβ report messages to syslog as well as to standard output or standard error. All messages will be logged with facilityLOG_DAEMON. Regular messages that are displayed on standard output are logged with levelLOG_NOTICE. Errors that don't causekrenewto terminate when run with-iare logged with levelLOG_WARNING. Fatal errors are logged with levelLOG_ERR.
This is useful when debugging problems in combination with -b. π
-ppid file β save the process ID (PID) of the runningkrenewprocess into pid file. pid file is created if it doesn't exist and overwritten if it does exist. This option is most useful in conjunction with-bto allow management of the runningkrenewdaemon.
Note that, when used with-bthe PID file is written out afterkrenewis backgrounded and changes its working directory to/, so relative paths for the PID file will be relative to/(probably not what you want). π
-sβ normally, whenkrenewexits abnormally while running a command (if, for example, the ticket's renewable lifetime has expired), it leaves the command running. If-sis given, it will send aSIGHUPsignal to the command before exiting. This can be useful if it's pointless for the command to keep running without Kerberos tickets.-tβ run an external program after getting a ticket. The intended use of this is to runaklogto get a token. If the environment variableAKLOG(orKINIT_PROGfor backward compatibility) is set, it overrides the compiled-in default.
If a command was given on the command line, krenew will attempt to isolate the AFS credentials for that command from the invoking process. There are two possible ways in which this is done. π¦
- First, if
krenewhas been built with AFSsetpag()support and AFS is available,krenewwill create a new PAG before running the external program. - Otherwise, if either
krenewwas not built with AFSsetpag()support or AFS is not available, but the Linux kafs module is available andkrenewwas built with libkeyutils support, it will create a new session keyring and link it to the current user keyring before running the external program. - If neither of these conditions are true,
krenewwill run the external program without doing any credential isolation, which may also affect the credentials of the invoking process.
-vβ be verbose. This will print out a bit of additional information about what is being attempted and what the results are. She's chatty, we love her. π-xβ exit immediately on any error. Normally, when running a command or when run with the-Koption,krenewkeeps running even if it fails to renew the ticket cache as long as the ticket cache still exists and appears to be renewable. It tries again at the next check interval. With this option,krenewwill instead exit.
π EXIT STATUS π
The program normally exits with status 0 if it successfully renews a ticket. If krenew runs aklog or some other program, krenew returns the exit status of that program if it exits normally. If the program exits abnormally due to a signal, krenew will exit with a status of 128 plus the signal number. (This matches the behavior of bash.) π
πΈ EXAMPLES πΈ
okay bestie, this is the part where it all clicks, fr fr. real-life scenarios, let's go π
1. renew the ticket you already have
want to renew the current ticket-granting ticket? iconic, no arguments needed:
krenew
2. wake up every ten minutes and check
this one naps for ten minutes at a time, wakes up, checks if the ticket cache needs renewing, and if it does, it re-runs aklog too. multitasking queen β¨
krenew -K 10 -t
3. background job, default hourly check, PID file, fresh AFS token
run /usr/local/bin/compute-job in the background, checking every hour to see if the ticket needs a glow-up (that's the default btw), drop the PID of the krenew job into /var/run/compute.pid, and grab a brand-new AFS token every single time the ticket gets renewed:
krenew -b -t -p /var/run/compute.pid /usr/local/bin/compute-job
4. passing options to the thing you're running
and if you wanted to hand options over to /usr/local/bin/compute-job itself? you'd need to sneak a -- argument in front of it, otherwise krenew is gonna be nosy and interpret those options as its own. rude of it, honestly, but that's just how it is π
the redirect plot twist (read this one, it's important) π«Ά
if you want to redirect output to a file that needs authentication to write to, you have to do that redirection inside a sub-shell. so like, this command right here:
krenew -t compute-job > /afs/local/data/output
won't work if /afs/local/data/output needs an AFS token to write to. π here's why: the job, while it's running, does have an AFS token β but the output redirection happens in the parent shell, which is not getting any of that krenew magic. the parent shell is just standing there. tokenless. unbothered. useless.
so instead, you write it like this:
krenew -t -- sh -c 'compute-job > /afs/local/data/output'
with this version, the shell doing the redirection is also running under krenew, so it gets the benefit of the AFS token krenew obtains. slay π
π¦ ENVIRONMENT π¦
these are the env vars krenew is looking at, bestie:
- if the environment variable
AKLOGis set, its value gets used as the program to run with-t, instead of the default compiled intokrenew. - if
AKLOGis not set andKINIT_PROGis set, thenKINIT_PROG's value gets used instead.
okay so about KINIT_PROG β it's honored for backward compatibility, but using it is not recommended, because its name is genuinely confusing. like, why is it called that. iykyk π
and one more thing: if no ticket file (that's -k) and no command is specified on the command line, krenew will use the environment variable KRB5CCNAME to figure out where the ticket-granting ticket lives. and if the -k option is used, KRB5CCNAME gets set to point at the ticket file before running the aklog program or any command you gave on the command line. so it's all lined up before anything else happens π
π FILES π
- the default ticket cache is determined by the underlying Kerberos libraries (not
krenew's call, it just trusts them π«Ά). - the default path for
aklogis determined at build time, and will normally be whichever ofaklogorafslogis found in the user's path.
π AUTHORS π
krenew was written by Russ Allbery <eagle@eyrie.org>.
it was based heavily on k5start by Booker C. Bense, which in turn was based on the k4start code written by Robert Morgan. a whole lineage, honestly β main character energy passed down through the generations π
π COPYRIGHT AND LICENSE π
Copyright 2015, 2021 Russ Allbery <eagle@eyrie.org>
Copyright 2006, 2008-2012, 2014 The Board of Trustees of the Leland Stanford Junior University
Copying and distribution of this file, with or without modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty.
SPDX-License-Identifier: FSFAP
β SEE ALSO β
this program is part of kstart. the current version is available from its web site at <https://www.eyrie.org/~eagle/software/kstart/>.
and that's a wrap on the whole page, bestie!! π«Ά this was krenew, from kstart version 4.3, dated 2021-08-31. go renew something. go get that token. periodt π
β¨
π¦ where this page comes from
- alpine 3.24: kstart-doc 4.3-r1 Β· custom
- debian bookworm: kstart 4.3-1 Β· MIT
- debian trixie: kstart 4.3-1 Β· MIT
- epel 9: kstart 4.3-1.el9 Β· MIT
- ubuntu jammy: kstart 4.3-1 Β· MIT
- ubuntu noble: kstart 4.3-1 Β· MIT
- ubuntu resolute: kstart 4.3-1build1 Β· MIT
- ubuntu stonking: kstart 4.3-1build1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms