In the closing days of 2015, the lights went out across a swath of Ukraine as Russian hackers remotely took over an electric utility’s control center and flipped off one power station after another, while the company’s operators stared at their screens helplessly.

The next year, the same thing happened, this time around Kyiv, the capital.

Now the United States and Britain have quietly dispatched cyberwarfare experts to Ukraine in hopes of better preparing the country to confront what they think may be the next move by President Vladimir Putin of Russia as he again menaces the former Soviet republic: Not an invasion with the 175,000 troops he is massing on the border, but cyberattacks that take down the electric grid, the banking system, and other critical components of Ukraine’s economy and government.