Created attachment 1395 [details] patch for removing staled credentials in .Xauthority ssh does not remove its entries in xauthority file and makes it grow. Lookup in too big a file might take lots of time, especially when the machine is not connected to the Internet or if the file stores hostnames that do not exist any more. There are probably many ways how to fix this issue. I am attaching a patch for openssh 4.7p1 we are using in openSUSE, that attempts to address it.
How does this work with session multiplexing? Wouldn't it be better to remove the creds once, when the server is finally closing?
It works with session multiplexing, at least as far as I have tested it. And as far as I understand it, it is done correctly, because every session, even the multiplexed one, does its X forwarding on its own.