What several of these generals share is a rocky history in the Obama administration. The White House forced General Flynn out of his last job, citing poor management of an agency with 20,000 employees. General Mattis, who oversaw military operations in the Middle East and Southwest Asia from 2010 to 2013, had his tour cut short by the Obama administration, which believed he was too hawkish on Iran. General Kelly opposed the administration’s plan to shut down the military prison at Guantánamo Bay, Cuba.

Mr. Obama fired General McChrystal after he disparaged other officials in an interview with Rolling Stone, while Mr. Petraeus, as C.I.A. director, failed in his effort to persuade Mr. Obama to supply arms to moderate rebels in Syria. Mr. Obama eventually did provide the weapons, and Mr. Petraeus’s resignation in 2012 was prompted by an unrelated scandal involving his disclosure of classified material.

For Mr. Trump, the strained history of these generals with his predecessor is less a liability than a credential.

“He is sticking his tongue out at the prior administration,” said Richard H. Kohn, a professor emeritus of history at the University of North Carolina at Chapel Hill who has written about civilian control of the military. “He is inherently distrustful of the military people that the system throws up at him. He thinks they’re not strong people. They are Obama’s generals.”

Mr. Trump might also view generals in his administration as a political asset. At a time when trust in institutions like Congress and the news media is eroding, the military remains enduringly popular. General Mattis, in particular, commands wide respect from uniformed men and women — especially Marines, who revere him as one of their own. On Sunday, Mr. Trump wrote on Twitter that General Mattis was a “true General’s General.”

Stephen K. Bannon, the president-elect’s chief strategist, said the incoming administration was looking at potential cabinet officials with combat experience so that people who had fought in wars would be making decisions about whether to commit the country to more of them.