Good question. This answer is going to focus on how the Jet Propulsion Lab handles this problem, as described mostly in "Managing Knowledge and Learning at NASA and the Jet Propulsion Laboratory (JPL)", a Harvard Business School publication (2002) (if someone can find a more stable link, please edit it in), and also "Architecting an Approach to Knowledge Management", NTRS (2001).
These are somewhat dated, but as far as I can tell the agency is following through on the initiatives laid out by in these documents. These (particularly the HBS publication) are quite good reads, and I'll try to summarize below.
Jeanne Holm, the "Chief Knowledge Architect" for NASA, identified three main challenges:
How do we [(NASA)] successfully transfer information gleaned from one mission to other missions and across generations of people who come in and out of the agency?
How do we get hugely diverse, geographically distributed communities to work together on complex space missions?
How do we manage the knowledge that we already have?
Her response to these challenges was three-fold. First, redesigning NASA's underutilized internal lessons learned system. "Lessons learned" is a catch-all term for bits of information and advice a team captures during their experience working on the project (an oft-occurring example: "Lock the mission requirements down at a specific date, and do not allow the sponsor to change them after this date."). Unfortunately capture of lessons learned is often a difficult process, as mission managers are reluctant to record all of the bad decisions that may have been made, for fear of them negatively affecting their reputation as a manager. The redesign of the system (the Lessons Learned Information System (LLIS)) addresses these concerns (unfortunately my source does not go into detail beyond that).
Second, a variety of online tools were developed -- essentially what we today would consider a wiki. The idea was to allow "staffers... to search efficiently for information useful to internal and external agency constituents." The idea of these tools was to foster collaboration and aid in knowledge sharing in a system that could also serve as a sort of archive.
The third initiative was something called the Academy of Program and Project Leadership (APPL). I'll let the source speak for this one:
Through its Knowledge Sharing Initiative (KSI), APPL supported best-practice communities and a culture of sharing knowledge through grass-roots efforts across the agency. KSI worked with centers to identify best-of-best managers and bring them together to share project-related stories in a series of workshops. Once or twice a year, KSI brought a group of such managers from all over NASA to meet one another. The head of APPL, Edward Hoffman, contended that APPL was crucial to NASA's efforts to capture and share expertise that was impossible to load onto databases.
In addition to these, Holm suggests that a cultural shift needs to happen at the agency level, and initiatives "such as expanding our mentoring programs, creating oral histories, and creating the time and incentives for mentoring" are needed.
The above largely addresses how to preserve the "know-how". Preserving the "interest" is, hopefully, relatively easy, as the missions tend to be extremely interesting in their own right (as anecdotally evidenced by the relatively large community of people who consider the missions interesting enough to discuss in their free time ;) ).