WASHINGTON — President Obama said for the first time on Friday that he had held back from retaliating against Russia’s meddling in the presidential race for fear of inciting further hacking “that could hamper vote counting.” But he said he was weighing a mix of public and covert actions against the Russians in his last 34 days in office, actions that would increase “the costs for them.”

Mr. Obama said he was committed to sending the Kremlin a message that “we can do stuff to you,” but without setting off an escalating cyberconflict.

“There have been folks out there who suggest somehow if we went out there and made big announcements and thumped our chests about a bunch of stuff, that somehow it would potentially spook the Russians,” he said. “I think it doesn’t read the thought process in Russia very well.”

The president did not reveal what steps he was considering and suggested that some of the options, if they were carried out, could remain secret. “Some of it we will do in a way that they will know, but not everybody will,” he said.