You should be able to attach to the screen session, create a new window/'screen' inside of it (with the default config, you can do this by pressing C-a C-c
), and just run kinit && aklog
. You do not need to run this "inside" the existing running applications or anything like that; you just need to run it somewhere within the same screen session. After that, you can detach the screen and logout, and the screen session should still have your credentials (until they expire; you can use krenew
to keep them going for a big longer, but not forever).
A more detailed explanation of what's going on, if you want to know. I'm assuming you are logging in via ssh and PAM is being used, but the same general process works for other setups, as well:
When you first login, PAM assigns you a PAG (a kind of container for your AFS tokens), and runs something that is somewhat equivalent to kinit
and aklog
to give you AFS tokens inside that PAG. Your shell is then run inside that PAG, so everything that you run in that shell is associated with that PAG and its credentials. That includes the screen
session you created.
When you logout, the PAM configuration says to destroy your credentials, which means it destroys the AFS tokens associated with that PAG. That's why the screen session loses credentials and loses access to your home directory: the tokens for that PAG have been destroyed.
Later on, if you login again, you're assigned a new separate PAG, and again you get AFS tokens. The old screen session is still associated with the other PAG, the one where the tokens are destroyed. So if you attach to that screen session, and run kinit
and aklog
somewhere inside of it, that will create new tokens that are associated with the old PAG from the first time you logged in. You can then detach from the screen session and logout, and the tokens in your current PAG will be destroyed. But the PAG for the screen session is untouched, since neither PAM nor anything else knows about that PAG anymore. So the tokens for it will continue to be valid until they expire.