An ex-CIA technician believed to be behind one of the worst leaks in agency history says the conditions at the federal jail in lower Manhattan are so bad that he’d rather be a prisoner in North Korea.

Joshua Schulte, who also faces kiddie porn charges, described the Metropolitan Correctional Center as a living hell where inmates are “dragged from their cages and beaten and maced,” forced to bathe in “s–t-filled showers,” thrown into solitary confinement for no reason and improperly barred from communicating with their lawyers.

“They even refuse us pens and stamps so we can’t even write,” Schulte told a judge in a letter that he says he was only able to write after he borrowed a pen from a medical assistant.

Schulte, who is accused of leaking national security information to Wikileaks, went so far as to compare his situation to Otto Warmbier, the American college student who was returned home from North Korea in a coma after being arrested for stealing a poster.

“Otto Warmbier received better treatment and more justice in North Korea than I have received in America,” Schulte whined.

The ex-CIA software engineer has been in the MCC since last year after the feds raided his New York apartment on suspicion that he had leaked classified documents to WikiLeaks.

Immediately following the raid, he was only charged with possession of kiddie porn, which the FBI found on his computer. It wasn’t until this year that the feds slapped Schulte with a 13-count superseding indictment for leaking classified information, including national defense information, that he believed could be used “to the injury of the United States and the advantage of a foreign nation.”

The questionable comparison to North Korea notwithstanding, the MCC has been the target of numerous complaints in recent months.

Reputed mobster John “Porky” Zancocchio recently got sprung from the lockup, where he was sent for a bail violation, after his lawyer complained that the food there was hurting his client’s already failing health.

After being released Zancocchio told The Post the place was riddled with waterbugs, including in the food.

The lawyer for a California man accused of carrying around explosive devices also recently leaned on the “deplorable” conditions at the MCC in a bid to get his client a sentence of time served.

Federal defender Martin Cohen argued that Arsenio Mason had already suffered enough by being forced to live at the prison facility alongside violent inmates like El Chapo for 18 months before being sentenced.

“I’ve been doing this for 10 years. The conditions at the MCC have deteriorated significantly during that time,” Cohen told the judge at Arsenio’s Sept. sentencing.

“It is ridden with mice, with bugs, folks are not adequately fed,” he said. “It is overcrowded and inmates never get to go outside,” he said.

“When the government asks for more incarceration it doesn’t take any responsibility for the conditions at these facilities,” he said.

The Bureau of Prisons didn’t immediately return a request for comment.