An Idaho man was sentenced to 25 years in prison on Monday for opening fire on the White House in November 2011.

Oscar R. Ortega-Hernandez, 23, pleaded guilty in federal court in Washington in September to using a semi-automatic assault rifle to fire at least eight rounds at the second and third floors of the White House.

No one was injured, but federal investigators recovered bullets from the window frame of the Truman Balcony. Another bullet struck the roof in close proximity to where Secret Service officers were on duty.

Before the shooting, court documents say Ortega-Hernandez told acquaintances that he “needed to kill” the president, and he recorded videos of himself in which he called for a revolution. He then drove more than 2,000 miles from his home in Idaho Falls to Washington.

“He was motivated by hatred for the president and the desire to start a revolution against the federal government,” Ronald C. Machen Jr., the U.S. attorney for the District of Columbia, said in a statement after the sentencing by U.S. District Judge Rosemary M. Collyer. “We are very fortunate that his bullets narrowly missed the U.S. Secret Service officers guarding the White House that night.

The judge also ordered Ortega-Hernandez to pay about $94,000 in restitution to cover the cost of the damage to the White House.

Get updates on your area delivered via e-mail