The U.S. government has not figured out how to deter the Russians from meddling in democratic processes, and stopping their interference in elections, both here and in Europe, is a pressing problem, the top civilian leader of the National Security Agency said.

The NSA was among the intelligence agencies that concluded that Russian President Vladi­mir Putin ordered a cyber-enabled influence campaign in 2016 aimed at undermining confidence in the election, harming Democratic nominee Hillary Clinton and helping elect GOP nominee Donald Trump.

“This is a challenge to the foundations of our democracy,” said NSA Deputy Director Richard Ledgett, 58, who is retiring at the end of April, in an interview at Fort Meade, Md., the agency’s headquarters. “It’s the sanctity of our process, of evaluating and looking at candidates, and having accurate information about the candidates. So the idea that another nation state is [interfering with that] is a pretty big deal and something we need to figure out. How do we counter that? How do we identify that it’s happening — in real time as opposed to after the fact? And what do we do as a nation to make it stop?”

The lack of answers, he said, “as an American citizen . . . gives me a lot of heartburn.”

Ledgett, known as a straight-shooting, unflappable intelligence professional, began his NSA career in 1988 teaching cryptanalysis — how to crack codes — and rose to become the agency’s top civilian leader . The NSA, with 35,000 civilian and military employees, gathers intelligence on foreign targets overseas through wiretaps and increasingly by cyberhacking. Its other mission is to secure the government computers that handle classified information and other data critical to military and intelligence activities.

Asked whether the NSA had any inkling that the Kremlin was going to orchestrate the release of hacked Democratic National Committee emails last July, he demurred. “I actually don’t want to talk about that.”

At the same time, he said, what Moscow did was “no strategic surprise.” Rather, “what may have been a tactical surprise was that they would do it the way they did.”

Campaigns of propaganda and disinformation, dating back to the Soviet Union, have long been a staple of the Kremlin’s foreign policy. Now, however, it is making effective use of its hacking prowess to weaponize information and combine it with its influence operations, or what intelligence officials call “active measures.”

“In general, if you’re responding to nation-state actions like that, you have to find out what are the levers that will move the nation-state actors and are you able and willing to pull those levers?” said Ledgett when asked how the United States should respond.

The Obama administration slapped economic sanctions on two Russian spy agencies involved in hacking the DNC, three companies believed to have provided support for government cyber operations, and four Russian cyber officials. The administration also ordered 35 Russian operatives to leave the United States and shut down Russian-owned facilities on Maryland’s Eastern Shore and on Long Island believed to have been used for intelligence purposes.

Yet, intelligence officials including NSA Director Michael S. Rogers and FBI Director James B. Comey said on Monday that they believe Moscow will strike again — in 2020, if not in 2018.

[FBI Director Comey confirms probe of possible coordination between Kremlin and Trump campaign]

So should the government mull other options, such as hacking Russian officials’ emails or financial records and releasing them in a bid to embarrass or show corruption? “I think every element of national power is something we should consider,” he said. “That would probably fall under something like a covert action. But if that’s the right answer, that’s the right answer.”

Ledgett is probably most well known for leading the agency task force that handled the fallout from the leaks of classified information by former NSA contractor Edward Snowden in 2013. The disclosures prompted a national and global debate about the proper scope of government surveillance and led Congress to pass some reforms, including the outlawing of bulk collection of Americans’ phone metadata.

But the disclosures also caused great upheaval in NSA’s collection efforts, hurt morale, and damaged relations with allies and with tech firms that enable court-ordered surveillance, Ledgett said. “It was a terrible time for the agency,” he said.

He oversaw the probe of the internal breach; relations with Congress, the White House, foreign governments and the press; and the effort to prevent a recurrence. “There was a bit of a narrative on the outside about this evil agency that hoovered up all the communications in the world and rooted through them for things that were interesting, and that wasn’t actually true.”

The operational hit was significant, he said. More than 1,000 foreign targets — whether a person or a group or an organization — altered or attempted to alter their means of communications as a result of the disclosures, he said. They “tried with varying degrees of success to remove themselves from our ability to see what they were doing,” he said.

The agency, which has some 200 stations worldwide, reworked capabilities including virtually all of its hacking tools. “In some cases, we had to do things very differently” to gather the same foreign intelligence as before.

Raj De, a former NSA general counsel, said Ledgett was relied on heavily by both Rogers and Rogers’s predecessor, Keith B. Alexander. “He has really been a source of steadiness for the agency,” said De, now head of the Cybersecurity & Data Privacy practice at Mayer Brown, a global law firm. “What is particularly notable about Rick is his willingness to engage with all types of people, to keep an open mind.”

In December 2013, Alexander, when he was the NSA director, said that Snowden should be given no amnesty. But Ledgett told CBS’s “60 Minutes” then that “my personal view is yes, it’s worth having a conversation about.”

In his interview earlier this week, however, he said what he meant was that by engaging Snowden in conversation, the agency might have been able to learn what material had not been released and where it was.

Today, he said, there is no longer any need to talk to Snowden. “He’s past his usefulness to us.” Snowden, who is living in Moscow under a grant of asylum, has been charged with violating the Espionage Act, and Ledgett said he should not be pardoned. “I’ve always been of the idea that ‘Hey, I think he needs to face the music for what he did.’ ”

Julie Tate contributed to this report.