Destroy expired tickets?

Stefan Monnier monnier at iro.umontreal.ca
Thu Nov 6 20:53:45 EST 2008


>> They're useless at best, and in some cases they're positively harmful
>> (their presence prompts `ssh' to contact the KDC to try and delegate
>> credentials, which is a waste if the tickets are expired, and is really
>> annoying when the KDC times out because it's behind a firewall).
> Hm, that sounds a bit broken.  I could see, maybe, inferring that you want
> to use Kerberos and prompting to get new tickets, but trying to forward
> expired ones is no good...

Does that mean that the session below (in Debian testing) is a sign of
a bug in OpenSSH or in Kerbers?

>> But I couldn't find any command that would destroy only expired tickets.
>> Any idea what I should use?  I guess I could try and parse the date&time
>> in "klist", but it'd be a pain in the rear and blatantly brittle.
> Running "klist -s" and testing the exit status should let you figure out if
> there are currently-valid tickets.  I don't know if there's a way to test
> for "tickets exist and are not valid", though perhaps "klist >& /dev/null"
> (C shell syntax) succeeding and "klist -s" failing would do the job.
> Or you could try "klist -s" and then just run "kdestroy >& /dev/null",
> ignoring any errors caused by a ticket cache not existing.

Oh, I didn't realize that "klist" returns a status that indicates
whether there are still valid keys.  That might be good enough to hack
something up (I don't expect I'll often bump into the case where I have
some valid keys mixed in with some expired keys).

Still, a better solution (for me anyway) would be for the Kerberos
library to automatically throw away expired keys when it encounters
some,


        Stefan


The session below shows a "typical" situation for me: I have some left
over tickets from last time I used the machine, but contacting the KDC
times out because I haven't restarted the VPN.  The session also shows
that the KDC is contacted twice (in sequence) and that by the time those
two attempts time out, the remote sshd server has already given up and
closed the connection, so I don't even get a chance to type in
my password.


% date
jeudi 6 novembre 2008, 20:37:38 (UTC-0500)
% klist
Ticket cache: FILE:/tmp/krb5cc_20848
Default principal: monnier at ADS.IRO.UMONTREAL.CA

Valid starting     Expires            Service principal
11/06/08 09:46:40  11/06/08 19:46:44  krbtgt/ADS.IRO.UMONTREAL.CA at ADS.IRO.UMONTREAL.CA
        renew until 12/04/08 09:46:40
11/06/08 09:46:49  11/06/08 19:46:44  host/trex.iro.umontreal.ca at ADS.IRO.UMONTREAL.CA
        renew until 12/04/08 09:46:40


Kerberos 4 ticket cache: /tmp/tkt20848
klist: You have no tickets cached
% ssh -v iro 
OpenSSH_5.1p1 Debian-3, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /home/monnier/.ssh/config
debug1: Applying options for iro
debug1: Applying options for *
debug1: /home/monnier/.ssh/config line 58: Deprecated option "UseRsh"
debug1: /home/monnier/.ssh/config line 59: Deprecated option "FallBackToRsh"
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: auto-mux: Trying existing master
debug1: Control socket "/tmp/monnier/trex.iro.umontreal.ca-monnier-22" does not exist
debug1: Connecting to trex.iro.umontreal.ca [132.204.27.213] port 22.
debug1: Connection established.
debug1: identity file /home/monnier/.ssh/identity type -1
debug1: identity file /home/monnier/.ssh/id_rsa type -1
debug1: identity file /home/monnier/.ssh/id_dsa type 2
debug1: Checking blacklist file /usr/share/ssh/blacklist.DSA-1024
debug1: Checking blacklist file /etc/ssh/blacklist.DSA-1024
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.4
debug1: match: OpenSSH_4.4 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.1p1 Debian-3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 zlib at openssh.com
debug1: kex: client->server aes128-cbc hmac-md5 zlib at openssh.com
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'trex.iro.umontreal.ca' is known and matches the RSA host key.
debug1: Found key in /home/monnier/.ssh/known_hosts:7
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
Cannot contact any KDC for requested realm

debug1: Unspecified GSS failure.  Minor code may provide more information
Cannot contact any KDC for requested realm

debug1: Unspecified GSS failure.  Minor code may provide more information


debug1: Next authentication method: publickey
debug1: Offering public key: /home/monnier/.ssh/id_dsa
Connection closed by 132.204.27.213
~-255% 



More information about the Kerberos mailing list