The administration’s restraint grows out of a concern over the risk of escalation with North Korea, since the United States has far more vulnerable targets, from its power grid to its financial markets, than North Korea.

“There are a lot of constraints on us, because we live in a giant glass house,” said one official involved in the high-level debates. The official said the challenge was to find a mix of actions that “the North Koreans will notice” but that will not be so public that Mr. Kim’s government loses face and feels compelled to respond.

Several administration officials said the White House woke up late to the growing confrontation with North Korea, with senior officials not realizing at first the scope and long-term implications of the attacks on Sony for its plans for a Christmas Day release of “The Interview,” a crude comedy built around a far-fetched C.I.A. plot to have two bumbling journalists assassinate the young North Korean leader. But by last week, the combination of the destructive attack on Sony’s computers and the threat of attacks on moviegoers at any theater that showed the film sent the administration scrambling for a response.

In interviews over the past two days, officials said the president’s decision was to have the United States directly accuse the North Korean government — a public naming of the perpetrators that went beyond previous American criticism. Then the president, in his year-end news conference, cast Mr. Kim as an insecure leader so weak that he could be provoked by an outlandish satire, even while Mr. Obama castigated Sony Pictures for giving in to intimidation by withdrawing the film.

The attacks on Sony appear to have been routed through China and then conducted through servers in Singapore, Thailand and Bolivia. Each of the countries, officials said, had been contacted in an effort to cut off access for the hackers.

But the key is China. United States officials said that American efforts to block North Korea’s access to the Internet, which is available only to the military and the elite, would necessarily impinge on Chinese sovereignty. But they also saw in the confrontation a chance to work with the Chinese on a subject the two countries have been warily discussing for several years: Establishing “rules of the road” for acceptable behavior in cyberspace.

By some accounts, what the administration is trying to create is a computer equivalent to the Proliferation Security Initiative, an effort begun in the Bush administration, also aimed squarely at North Korea, to stop the shipment of nuclear materials and other weaponry. But in cyberspace that is a far harder task, since it is easier for the North Koreans to reroute computer code at lightning speed than to reroute a cargo ship carrying missiles.