Unable to add/use Internet Accounts after battery/SSD swap

My MacBook Pro 15" from 2015 was one with the unsafe battery. Because it had to be fixed my IT department took out the SSD and put it in an identical MBP with a safe battery, about a month ago. Everything worked fine after that swap (after re-applying some licenses because the serial number changed because of this). Today we received my fixed MBP and they put back the SSD in it. Unfortunately this worked not as well as last time:

I can no longer log in to any Internet Account (iCloud, Exchange, CalDAV, CardDAV, etc.) in System Preferences. Nor can I add such accounts after deleting them. The password is correct (I get errors when I intentionally type something else) and 2FA codes are requested where configured, but these setup flows never finish. They all fail adding the account at some point:

  • The iCloud flow just returns to the first screen (after adding only a Game Center account); requesting Apple ID and password over and over again.
  • The Exchange accounts allow me to select which type of data I want to sync (after the credentials are verified), but then the “Done” button changes into “Next” and when I click that I briefly see a spinner after which that “Next” button is enabled again…

All these accounts still work fine on a fresh local admin account that I created today on that machine. However, I have a fairly complex setup with lots of fine-tuning, SSH keys, passwords etc. that I rather not start setting up from scratch (and I don’t have a backup; we’re not allowed to do that to services/systems that are not controlled by IT).

Any tips on how to get Internet Accounts working again with the original local account?

It looks like something got corrupted during the swap, but what?

This helped: https://discussions.apple.com/thread/8393897

After deleting the (two, where the new Mac account had only one) subfolders in ~/Library/Keychains (this is dangerous?!), but not the files in that folder itself, I seem to be able to add all Internet Accounts again!

Hope this is indeed the solution and has no side-effects.

If so, this issue only cost me 12 hours today…